I am working with a site and currently the configurable color swatches show every single out of stock associated products' swatch color on the category page, but not on the product info page.

Is this default behaviour for Enterprise? Is there a way to fix this? I can't imagine it being default behaviour since the product info page displays only the in-stock options.

  • Great, worked for me. Think Magento and some themes did not factor configurable product in building the list template Commented Mar 20, 2018 at 18:41

1 Answer 1


You need to check product Stock & skip out of stocks color to your list.

You can did following code on


$_product = $this->getProduct(); 
/* get available instock products */
$instockProductsId = array(); 
$usedProductsArray = array();
$skip = false;
if($_product->getTypeId() == "configurable") {
    $usedProducts = $_product->getTypeInstance()->getUsedProducts();
    foreach ($usedProducts  as $child) {
             if ($child->isSalable()) {
                    $instockProductsId[]  = $child->getId();

    $skip = true;
        foreach($instockProductsId as $id){
            $color = Mage::getResourceModel('catalog/product')->getAttributeRawValue($id, 'color', $storeId);
            $usedProductsArray[$id] = $color;       
$usedProductsArray = array_unique($usedProductsArray);

then add if condition in foreach loop:

foreach ($_attrValues as $_optionValue => $_optionLabel):   
/* To skip out of stock product on list page */   
    if($skip && !in_array($_optionValue,$usedProductsArray)){

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.