Product grid 4 columns and certain pages 5 column with two rows of full products, how?
I am using a product grid and certain pages need 4 columns with two rows of 8 products on certain pages and 5 columns of two rows of 10 products on other pages.
I can get different columns, but not change the number of products that are set in the admin area. How would I override the default of 8 products开发者_高级运维 per a page for my 5 column pages?
Chris,
Your question is not very clear :) Do you want to change the number of products per row and/or the total number of products per page ?
If you want to change the number of products per row, the following should be enough
For each category where you want to display 10 products per row :
1- go the category in the backend and edit it.
2- go to the "Custom Design" tab and add the following in the "Custom Layout Update" field :
<reference name="product_list">
<action method="setColumnCount"><columns>10</columns></action>
</reference>
If you want to change the total number of products per page
In the following, if you have a default products count per page set up in the admin and you still want it to be diplayed in the pager select on the frontend, you must add it to the layout update. In the following example, the default products count is 10 and we want to display 20 products on given categories. For each category where you want to display 20 products per page :
1- go the category in the backend and edit it.
2- go to the "Custom Design" tab and add the following in the "Custom Layout Update" field :
<reference name="product_list_toolbar">
<!-- Your default products count : 10 -->
<action method="addPagerLimit"><mode>grid</mode><limit>10</limit></action>
<!-- Your new products count : 20. This is mandatory to be able to display 20 products -->
<action method="addPagerLimit"><mode>grid</mode><limit>20</limit></action>
<!-- The total number of products to display per page -->
<action method="setDefaultGridPerPage"><limit>20</limit></action>
</reference>
Now, let's mix both
We want to display 20 products per page, on 10 columns (so 2 rows of 10 products each)
<reference name="product_list">
<action method="setColumnCount"><columns>10</columns></action>
</reference>
<reference name="product_list_toolbar">
<!-- Your default products count : 10 -->
<action method="addPagerLimit"><mode>grid</mode><limit>10</limit></action>
<!-- Your new products count : 20 -->
<action method="addPagerLimit"><mode>grid</mode><limit>20</limit></action>
<!-- The total number of products to display per page -->
<action method="setDefaultGridPerPage"><limit>20</limit></action>
</reference>
Please note...
... that you must adapt your CSS / theme in order to make sure the 10 column < ul > is wide enough to enclose the 10 < li > this layout update will generate.
app\code\core\Mage\Catalog\Block\Product\Abstract.php
line no 66 change
protected $_defaultColumnCount = 3;
to
protected $_defaultColumnCount = 4;
Chris, could you please check the following file? There is a parameter which is DEFAULT_PRODUCTS_COUNT
app/code/core/Mage/Catalog/Block/Product/New.php
class Mage_Catalog_Block_Product_New extends Mage_Catalog_Block_Product_Abstract
{
protected $_productsCount = null;
const DEFAULT_PRODUCTS_COUNT = 5;
/**
* Initialize block's cache
*/
protected function _construct()
{
parent::_construct();
$this->addColumnCountLayoutDepend('empty', 6)
->addColumnCountLayoutDepend('one_column', 5)
->addColumnCountLayoutDepend('two_columns_left', 4)
->addColumnCountLayoutDepend('two_columns_right', 4)
->addColumnCountLayoutDepend('three_columns', 3);
$this->addData(array(
'cache_lifetime' => 86400,
'cache_tags' => array(Mage_Catalog_Model_Product::CACHE_TAG),
));
}
精彩评论