When a user performs a search the default Magento search result pages offers pagination, it defaults to 9 items per page. I'd like it to default to 30 items per page. How is this done?
2 Answers
You can achieve this by layout update. For this you need to follow these steps
Create local.xml
file
This is a special layout file that will process by Magento after processing every other layout updation files. So this file is a perfect place to do "alteration" works.
File: app/design/frontend/<package>/<theme>/layout/local.xml
<layout>
<catalogsearch_result_index>
<reference name="product_list_toolbar">
<action method="addPagerLimit"><mode>grid</mode><limit>30</limit></action>
<action method="addPagerLimit"><mode>list</mode><limit>30</limit></action>
</reference>
</catalogsearch_result_index>
</layout>
Explanation Of Code
As you can see, we are using a layout handle catalogsearch_result_index
, which is a unique handler for search pages. So any layout updates comes under this particular layout handle only affect in search result page. Next we have used an action addPagerLimit()
in a block product_list_toolbar
in order to set the page size.addPagerLimit()
uses two parameter for its internal operation. First parmeter specifies which list mode we need to alter. Basically there are two list modes. They are list
and grid
. Next parameter is the limit. This is used to set the toolbar size. So basically using our layout update, we set page size for all available list of modes that should only affect in search page.
Note: Don't forget to clear the cache
I think this is tied to the products in the category page, but i might be wrong. Values can be changed from
System > Configuration > Catalog > Catalog > Frontend
See this question also, it might be helpful if you only want to change the search.
-
You saved my day. I was looking everywhere else for this option!– AdnanCommented Sep 4, 2015 at 18:37