Magento hide in stock products

I have the option System->Configuration->Catalog->Inventory->Display Out of Stock Products set to No

But this spare item still exists in the category list. Does this configuration option work with a collection of products? How can I hide over-the-counter products from category product collections?

+4
source share
2 answers

To do this, go to System->Configuration->Catalog->Catalog and set Use Flat Catalog Product to Yes . After that, just run the Product Flat Index

+1
source

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.

+1
source

Source: https://habr.com/ru/post/1493085/


All Articles