I'm having a hard time on how to display those configurable products which associated products are in stock only.
For example, if I have a configurable product and the quantity stock status of its associated products are out of stock, then when I create a custom product collection, that configurable product will not be displayed or will not be included in my query.
Here's my custom collection code:
<?php $attributeCode = 'violator_tags'; // load attribute $attribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product', $attributeCode); $categoryLink = Mage::getModel("catalog/category")->load(146)->getUrl(); //146 category ID of BestSeller //get option id and label array if ($attribute->usesSource()) { $options = $attribute->getSource()->getAllOptions(false); } $products = Mage::getModel('catalog/product') ->getCollection() ->addAttributeToSelect('*') ->addAttributeToFilter( array( array('attribute'=>$attributeCode, 'finset'=>132) ) ) ->addAttributeToFilter('status', 1); // show only enabled products Mage::getSingleton('catalog/product_status') ->addVisibleFilterToCollection($products); Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($products); // show only visible products Mage::getSingleton('catalog/product_visibility') ->addVisibleInCatalogFilterToCollection($products); ?> Currently, it displays the configurable products with OUT OF STOCK associated products. Did I miss something?
Using Magento 1.9 CE Please help.
Thanks.