Change Default Products Per Page in Magento 1.8 Search Results

catalogsearchmagento-1.8pagination

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?

Best Answer

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

Related Topic