简体   繁体   English

magento缺货时如何隐藏产品属性

[英]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 我在Magento中使用EMtheme

You need to add some code in Navigation.php of app/code/core/Mage/Catalog/Block Folder. 您需要在app/code/core/Mage/Catalog/Block文件夹的Navigation.php中添加一些代码。 Override Navigation.php in your local package and paste the following code. 在您的本地包中覆盖Navigation.php并粘贴以下代码。

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;

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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