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')
                                  array('attribute'=>$attributeCode, 'finset'=>132)
                ->addAttributeToFilter('status', 1);                       

  // show only enabled products   


 // show only visible products 

Currently, it displays the configurable products with OUT OF STOCK associated products. Did I miss something?

Using Magento 1.9 CE Please help.


1 Answer 1


Please try this, code is not tested

$attributeCode = 'violator_tags';
$category = Mage::getModel('catalog/category')->load(Mage::app()->getStore()->getRootCategoryId());

$collection = $category->getProductCollection();

                      array('attribute'=>$attributeCode, 'finset'=>132)

  • Hello! Thanks for the suggestion and I tried it but it didn't work. The configurable product with OUT OF STOCK associate products is still there. When I click the configurable product, this is the result. prnt.sc/euy69b
    – nosnevetzy
    Commented Apr 11, 2017 at 1:39
  • I was just trying to display the products on the homepage. This is the result when I tried your suggested code. prnt.sc/euy70q . You can see that the configurable product is still there. It should be removed since there are NO IN STOCK associated products on it. Please help. Thanks!
    – nosnevetzy
    Commented Apr 11, 2017 at 1:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.