Search code examples
imagemagento-1.9

Show Cross image on out of stock product in default swatches


How i can show an cross image on out of stock item in default color swatches in Magento 1.9

For example if we have Product with these two attribute

1) Size 8|9|10

2) Color Green | Yellow | Magento

And suppose if product with size 8 and color green is out of stock then when we choose size 8 and color green then size image must be show as a crossed image


Solution

  • Not 100% sure, but I think that you'll achieve what you want by modifying line 151 of Mage_Catalog_Block_Product_View_Type_Configurable:

    if(!$this->_validateAttributeValue($attributeId, $value, $options)) {
       $inStock = false;
    }
    

    Then later, at line 170, you can include this flag in options array:

    $info['options'][] = array(
        'id'        => $value['value_index'],
        'label'     => $value['label'],
        'price'     => $configurablePrice,
        'oldPrice'  => $this->_preparePrice($value['pricing_value'],          
        $value['is_percent']),
        'products'  => $productsIndex,
        'stock'     => $inStock
    );
    

    It did fine for me.