Magento hide out of stock products -
i have system->configuration->catalog->inventory->display out of stock products
option set no
.
but out-of-stock products still exist in category list. config option works product collection? how can hide out-of-stock products category product collections?
do following.
go app/code/core/mage/catalog/block folder , copy navigation.php
. override navigation.php
in local package. open navigation.php
of package , paste following code in 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 hide out of stock products or empty category top menu.
Comments
Post a Comment