How can I change Magento's default grid per page in my local.xml?
New to magento here, I have figured out how to use my local.xml to do just about all the changes I need but the grid view has me stumped. I have changed my grid view to 5 columns, so the default 9 items displayed looks sloppy. I want to set it to a multiple of 5. Looking开发者_C百科 through catalog.xml I figured this should do it:
<reference name="product_list_toolbar_pager">
<action method="setDefaultGridPerPage"><limit>15</limit></action>
</reference>
within both category_catalog_default and category_catalog_layered handles, but no dice. I am struggling with Magento's scattered documentation, but actually coming to appreciate the whole layout thing.
I'm on 1.5.1, if that makes a difference.
Took me a long time to figure this one out. As it turns out, the pager values are set through the admin. System > configuration > catalog > catalog > frontend > "Products per Page on Grid Default Value"
I know this question is answered, but I fond myself here.
You can use XML like this:
<reference name="product_list_toolbar">
<action method="setDefaultGridPerPage"><limit>30</limit></action>
</reference>
In either a local.xml
file or in the Category Custom Design
field.
What is worth noting though is that the limit has to one of the values in the list within System Config Catalog pages.
Bit of an old question, but I stumbled across this answer on Google and thought this could be beneficial to someone.
The values set in the admin section don't work for me - I think the theme I'm currently using is overriding it. For those of you who want/need to make this change via local.xml instead, here's a way of doing it.
Looking at catalog.xml it might seem reasonable to nest setDefaultGridPerPage under product_list_toolbar_pager, that's what I thought too, but that is a self-closing tag and I didn't spot that. What you want to do is nest it under product_list_toolbar instead.
<catalog_category_layered>
<reference name="product_list_toolbar">
<action method="setDefaultGridPerPage">
<limit>15</limit>
</action>
</reference>
</catalog_category_layered>
<catalog_category_default>
<reference name="product_list_toolbar">
<action method="setDefaultGridPerPage">
<limit>15</limit>
</action>
</reference>
</catalog_category_default>
This solved the problem for me, at the very least. Your proverbial mileage may vary.
<five_column_grid>
<reference name="product_list">
<action method="setColumnCount">
<count>5</count>
</action>
</reference>
</five_column_grid>
<catalog_category_default>
<update handle="five_column_grid" />
</catalog_category_default>
<catalog_category_layered>
<update handle="five_column_grid" />
</catalog_category_layered>
It should automatically adjust the pager for you.
Have fun :)
精彩评论