Une autre manière de faire :
surcharger app\code\core\mage\block\navigation.php en rajoutant cette fonction :
| Code : |
public function getCurrentBrotherCategories()
{
$layer = Mage::getSingleton('catalog/layer');
$categ = $this->getCurrentCategoryPath();
$categ = array_pop($categ);
$category = Mage::getModel('catalog/category')->load($categ);
/* @var $category Mage_Catalog_Model_Category */
$collection = Mage::getModel('catalog/category')->getCollection();
/* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection */
$collection->addAttributeToSelect('url_key')
->addAttributeToSelect('name')
->addAttributeToSelect('is_anchor')
->addAttributeToFilter('is_active', 1)
->addIdFilter($category->getChildren())
->joinUrlRewrite()
->load();
$productCollection = Mage::getResourceModel('catalog/product_collection');
$layer->prepareProductCollection($productCollection);
$productCollection->addCountToCategories($collection);
return $collection;
}
|
Ensuite dans app\design\frontend\default\default\template\catalog\navigation\left.phtml rajouter apres la ligne 28 :
| Code : |
<?php $_categories=$this->getCurrentChildCategories() ?>
|
ceci :
| Code : |
<?php if(!($_categories->count())): ?>
<?php $_categories=$this->getCurrentBrotherCategories() ?>
<?php endif; ?>
|
Ca devrait marcher.