I have this script to hide empty categories:
require_once '../app/Mage.php'; Mage::app()->setCurrentStore(0); $categories = Mage::getModel('catalog/category')->getCollection() ->addAttributeToSelect('*') ->addAttributeToFilter('level',array('gt'=>2)); foreach($categories as $category) { $products = $category->getProductCollection() ->addAttributeToFilter('status', 1); if(!$products->count()) { echo $category->getName().'-'; $category->setIsActive(0); } else { $category->setIsActive(1); } $category->save(); }
It hides categories with only de-activated products. But how can i extend this with a filter on products which have stock management, but are out of stock?