Skip to content

Instantly share code, notes, and snippets.

@mwin007
mwin007 / gist:ef5e45f2b428f56aca75
Created October 30, 2015 10:53
Form Validation, the Magento way…
http://www.human-element.com/form-validation-the-magento-way/
Notice the
class="input-text required-entry"
that’s what prototype looks at to determine whether or not to validate the field. This can be taken further than just “is there stuff in the field?” (required-entry) to maybe something like “are there only numbers in the field?” or “are there only 5 numbers in the field?”
@mwin007
mwin007 / gist:eaf3605b2e4978e46346
Created October 31, 2015 02:44
Set product reviews limit and pagination
http://connect20.magentocommerce.com/community/Foundation_CustomizableFraudFilters
<reference name="product.info">
<block type="page/html_pager" name="product_review_list.toolbar" />
<block type="core/template" name="product_review_list.count" template="review/product/view/count.phtml" />
<block type="review/product_view_list" name="product_customer_reviews" as="product_customer_reviews" template="review/product/view/list.phtml">
<block type="review/form" name="product.review.form" as="review_form">
<block type="page/html_wrapper" name="product.review.form.fields.before" as="form_fields_before" translate="label">
<label>Review Form Fields Before</label>
<action method="setMayBeInvisible"><value>1</value></action>
The file you're looking for is:
/app/code/core/Mage/Page/Block/Html/Pager.php
The line you want to modify to adjust review pagination limits is this one:
protected $_availableLimit = array(10=>10,20=>20,50=>50);
Replace the numbers with the review page limits that you'd prefer.
Of course, since this change is in core code, you'll first want to copy this file into /app/code/local/Mage/Page/Block/Html, and then make your change, to ensure that upgrades do not override it.
If you are looking to add magento reviews form to your product details form page, here is the step by step instructions for that.
Second, open: catalog.xml, in your “layout” directory. Find this section:
?
1
2
<reference name=”content”>
<block type=”catalog/product_view” name=”product.info” template=”catalog/product/view.phtml”>
Add the following:
<reference name="product.info">
<block type="page/html_pager" name="product_review_list.toolbar" />
<block type="core/template" name="product_review_list.count" template="review/product/view/count.phtml" />
<block type="review/product_view_list" name="product_customer_reviews" as="product_customer_reviews" template="review/product/view/list.phtml">
<block type="review/form" name="product.review.form" as="review_form">
<block type="page/html_wrapper" name="product.review.form.fields.before" as="form_fields_before" translate="label">
<label>Review Form Fields Before</label>
<action method="setMayBeInvisible"><value>1</value></action>
</block>
</block>
How do I implement Ajax/JQuery to an existing PHP MYSQL pagination script?
up vote
Pagination Tricks in Magento – Part 1
March 11, 2013 by Peter
Share:
twitter
facebook
Ajax paging in magento for custom module
February 14, 2015magentopractice
Today I have implemented Ajax paging in magento frontend. Please take a look it may help you.
Block file …
class Namesapce_ModuleName_Block_Productlist extends Mage_Core_Block_Template
{
@mwin007
mwin007 / gist:7296cb7f637e4fcd4306
Created November 1, 2015 18:09 — forked from tonyoconnell/gist:2351492
Install Magento 1.8 With Sample Data By SSH
mkdir demo
cd demo
wget http://www.magentocommerce.com/downloads/assets/1.8.1.0/magento-1.8.1.0.tar.gz
wget http://www.magentocommerce.com/downloads/assets/1.6.1.0/magento-sample-data-1.6.1.0.tar.gz
tar -zxvf magento-1.8.1.0.tar.gz
tar -zxvf magento-sample-data-1.6.1.0.tar.gz
mv magento-sample-data-1.6.1.0/media/* magento/media/
mv magento-sample-data-1.6.1.0/magento_sample_data_for_1.6.1.0.sql magento/data.sql
mv magento/* magento/.htaccess .
chmod o+w var var/.htaccess app/etc
Magento observer examples
When it comes to customize the magento code, there are following 4 options:
1. Creating a observer should be the first to consider.
2. Extending and overriding the core modules should be the second to consider when option 1 cannot fails to accomplish the objectives.
3. Copy the core class to the local directory and put it in the same directory path it was in core directory, this is should be avoided.
4. Modify the core class directly, this should definitedly be avoided unless you are just trying to test a code snippet.
So, there are really only two recommended options which is to try to create an observer first, if it doesn’t work out then write a module to extend and override the core module.
Here is an example of how to create an observer in Magento. This module has two observer: