Цитата
My solution was to create a module that overrides the Toolbar class which is what controls the grid/list view of the catalog and the number of items to display.
The specific class to override is called Mage_Catalog_Block_Product_List_Toolbar. Clone the file and add the following method to it:
/**
* Sets the current View mode (grid, list, etc.)
*
* @param string $mode
*/
public function setCurrentMode($mode)
{
$this->setData('_current_grid_mode', $mode);
}
You also need to create a config.xml file for it.
<!-- app/code/local/Example/Catalog/etc/config.xml -->
<?xml version="1.0"?>
<config>
<global>
<blocks>
<catalog>
<rewrite>
<product_list_toolbar>Example_Catalog_Block_Product_List_Toolbar</product_list_toolbar>
</rewrite>
</catalog>
</blocks>
</global>
</config>
Now, in the admin panel, to change the layout of a category, go to Catalog > Manage Categories and select the category that you wish to change. Go to the Custom Design tab and in the field labelled Custom Layout Update, enter the following XML code:
<reference name="product_list_toolbar">
<action method="setCurrentMode">
<mode>list</mode>
</action>
</reference>
Of course, remember to flush the layout caches of Magento or your change won't appear.
share|improve this answer
answered Dec 3 '10 at 18:26
omouse
The specific class to override is called Mage_Catalog_Block_Product_List_Toolbar. Clone the file and add the following method to it:
/**
* Sets the current View mode (grid, list, etc.)
*
* @param string $mode
*/
public function setCurrentMode($mode)
{
$this->setData('_current_grid_mode', $mode);
}
You also need to create a config.xml file for it.
<!-- app/code/local/Example/Catalog/etc/config.xml -->
<?xml version="1.0"?>
<config>
<global>
<blocks>
<catalog>
<rewrite>
<product_list_toolbar>Example_Catalog_Block_Product_List_Toolbar</product_list_toolbar>
</rewrite>
</catalog>
</blocks>
</global>
</config>
Now, in the admin panel, to change the layout of a category, go to Catalog > Manage Categories and select the category that you wish to change. Go to the Custom Design tab and in the field labelled Custom Layout Update, enter the following XML code:
<reference name="product_list_toolbar">
<action method="setCurrentMode">
<mode>list</mode>
</action>
</reference>
Of course, remember to flush the layout caches of Magento or your change won't appear.
share|improve this answer
answered Dec 3 '10 at 18:26
omouse
но не могу понять как его использовать. Можете мне подробней "разжевать", что по пунктам делать нужно?