Hi friends,
Many times we face a problem that we add categories to our magento store, but for one or more categories, we don't have products to show customer at that time.
In that case, we may not want to show that category in top menu, as it gives a bad impression to customers that there is no product in category.
You can hide that particular category from Top Menu, if it has no product. To do this, go to:
app/code/core/Mage/Catalog/Block Folder and copy Navigation.phpOverride Navigation.php in your local package.
Open Navigation.php of your package and paste below code in this file:
Save file and enjoy.. :)
Many times we face a problem that we add categories to our magento store, but for one or more categories, we don't have products to show customer at that time.
In that case, we may not want to show that category in top menu, as it gives a bad impression to customers that there is no product in category.
You can hide that particular category from Top Menu, if it has no product. To do this, go to:
app/code/core/Mage/Catalog/Block Folder and copy Navigation.phpOverride Navigation.php in your local package.
Open Navigation.php of your package and paste below code in this file:
if ($category->getIsActive()) {
$cat = Mage::getModel('catalog/category')->load($category->getId());
$products = Mage::getResourceModel('catalog/product_collection')->addCategoryFilter($cat);
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($products);
if(count($products)==0)
return;
}
Save file and enjoy.. :)
No comments:
Post a Comment