In your code to get the children categories from current category, which looks like this :
<?php
$layer = Mage::getSingleton('catalog/layer');
$_category = $layer->getCurrentCategory();
$_categories = $_category->getCollection()->addAttributeToSelect(array('url_key','name','image','all_children','is_anchor','description'))
->addAttributeToFilter('is_active', 1)
->addIdFilter($_category->getChildren())
->setOrder('position', 'ASC')
->joinUrlRewrite();
?>
Try with this code instead :
<?php
$layer = Mage::getSingleton('catalog/layer');
$_category = $layer->getCurrentCategory();
$_categories = $_category->getCollection()->addAttributeToSelect(array('url_key','name','image','all_children','is_anchor','description'))
->addAttributeToFilter('is_active', 1)
->addIdFilter($_category->getAllChildren(true))
->setOrder('position', 'ASC')
->joinUrlRewrite();
?>
Difference is, your call to method getChildren
returns a comma separated list of IDs, not an array, while the method addIdFilter
expects an array to be passed. When you pass true to the method getAllChildren
, it will return the list as an array.
I found the answer here, in another question. To clarify further; I went with the first approach, created a simple module and used the code from the said answer in my view/frontend/templates/subcategories.phtml
Then I use a custom layout update XML in the adminpanel for the categories where I want the code to show.
Best Answer
Add a static block into a static block: