Reputation: 79
In magento when we click on a category it takes us to category page and shows (if exists) subcategories of the clicked category in layered navigation on left.But when we click on a category that has no subcategories it show empty on that category page in layered navigation on left. What I want is to show subcategories of the parent if the current category has no subcategories.For this I have done the following but did not work for me.
I have tried to add the following to to
app/code/core/Mage/Catalog/Model/Layer/Filter/Category.php
if(count($categoty->getChildrenCategories())){
$categories = $categoty->getChildrenCategories();
}else{
$categories = $categoty->getParentCategory()->getChildrenCategories();
}
and removed line #163
$categories = $categoty->getChildrenCategories();
Please suggest me a solution. Any help will be greatly appreciated.
Upvotes: 0
Views: 443
Reputation: 79
I have found the solution. I have to put the above login in left.phtml
app/design/frontend/theme/template/catalog/navigation/left.phtml
$categoty = Mage::registry('current_category');
$categories = $category->getChildrenCategories();
//$_categories = $this->getCurrentChildCategories();
if(count($categoty->getChildrenCategories())){
$_categories = $categoty->getChildrenCategories();
}else{
$_categories = $categoty->getParentCategory()->getChildrenCategories();
}
and it worked like a charm! Hope it will help someone else!
Upvotes: 1