Magento 2 show different number of product for every category page

In this blogpost we will see how we can show different number of items or limit of a collection for every category page. For this you need to login to admin panel and follo following path:-

 Product > Category > Design > Layout xml update 

We have to update product_list_toolbar block and will set setDefaultListPerPage or setDefaultGridPerPage as per your page view type.

setDefaultListPerPage method will set limit for list page and setDefaultGridPerPage will set limit for grid page.

If you will try the below code:-

<referenceBlock name="product_list_toolbar">
        <action method="setDefaultListPerPage">
                 <argument name="limit" xsi:type="string">4</argument>
        </action>
 </referenceBlock>

There will be an issue that only allowed elements are referenceContainer, update, move. So the correct code that needs to be updated is

<referenceContainer name="content">
     <referenceBlock name="product_list_toolbar">
          <action method="setDefaultListPerPage">
             	 <argument name="limit" xsi:type="string">4</argument>
          </action>
    </referenceBlock>
</referenceContainer>

Change setting in admin configuration

Under configuration > catalog > catalog > storefront > Products per Page on List Allowed Values OR Products per Page on Grid Allowed Values set the limit whichever you are setting above. It is necessary else you will get default page value only.

Leave a Comment.