Magento LayoutXML Update Default Products per Page Grid
-
09-03-2021 - |
Question
I cannot edit my magento theme for now - I'm trying to do this through the back admin. I am also by no means an expert, so please forgive me.
I need one category to have a default grid value of 48 products instead of our set default value of 24. 48 is a value that is allowed in our product grid.
I tried the following code by entering it into the category Design Layout Update XML section, but it is not working.
<referenceContainer name="content">
<block class="Magento\Theme\Block\Html\Pager" name="product_list_toolbar_pager"><action method="setDefaultGridPerPage">
<argument name="limit" xsi:type="string">48</argument>
</action>
</block>
</referenceContainer>
How can I go about changing the default value via back admin?
Thanks in advanced!
La solution
To set a default grid value of 48 products for one category, you have to set "Products per Page on Grid Allowed Values" configuration in Store > Configuration > Catalog >Catalog > Store Front > Products per Page on Grid Allowed Values add 48. You will have to then move to catalog > categories (select the category in which you have to set default grid value to 48) > Design > Layout Update XML add below lines
<referenceBlock name="product_list_toolbar">
<action method="setDefaultGridPerPage">
<argument name="limit" xsi:type="string">48</argument>
</action>
</referenceBlock>
Autres conseils
You have to set 48 as value allowed in "Products per Page on Grid Allowed Values" ... in Store > Configuration > Catalog > Catalog > Store Front > Products per Page on Grid Allowed Values.
Go to catalog > categories and select the category in which you have to set default grid value to 48. Go to tab Design > Layout Update XML and add this:
You can paste from here:
<referenceContainer name="content">
<referenceBlock name="product_list_toolbar">
<action method="setAttribute">
<argument name="name" xsi:type="string">_current_limit</argument>
<argument name="value" xsi:type="number">48</argument>
</action>
</referenceBlock>
</referenceContainer>