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?
Change Default Products Per Page in Magento 1.8 Search Results
catalogsearchmagento-1.8pagination
Best Answer
You can achieve this by layout update. For this you need to follow these steps
Create
local.xml
fileThis 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
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 actionaddPagerLimit()
in a blockproduct_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 arelist
andgrid
. 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