Do the following.
Go to application / code / kernel / Mage / Directory / Lock folder and copy Navigation.php . Override Navigation.php in the local package. Open the Navigation.php your package and paste the following code into 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; }
This will lead to the fact that in the top menu there will be no product or empty category.
source share