简体   繁体   中英

How to Hide Products Attributes if it is out of stock magento

I Have Already Done this after referring various posts

Admin >> System >> Configuration >> Catalog >> Inventory >> Stock Options >> Display Out of Stock product to No

But still the attributes are shown in frontend.

Is there something to do with theme? I am using EMtheme in Magento

You need to add some code in Navigation.php of app/code/core/Mage/Catalog/Block Folder. Override Navigation.php in your local package and paste the following code.

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;

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM