1

On my Magento site I have configurable products. They have size and color attributes. How can I display products with sizes and colors that are out of stock? Now you can select only the color from from the products in stock and size also. If product is out of stock, combination of color/size isn't available for choosing. How to display all colors and sizes even from simple products out of stock?

P.S. I already set the configuration Display Out of Stock Products to Yes, but this is probably for catalog display, not attributes.

1

Goto

Mage / Catalog / Block / Product / View / Type / Configurable.php

public function getAllowProducts()
{
    if (!$this->hasAllowProducts()) {
        $products = array();
        $skipSaleableCheck = Mage::helper('catalog/product')->getSkipSaleableCheck();
        $allProducts = $this->getProduct()->getTypeInstance(true)
            ->getUsedProducts(null, $this->getProduct());
        foreach ($allProducts as $product) {
            if ($product->isSaleable() || $skipSaleableCheck) {
                $products[] = $product;
            }
        }
        $this->setAllowProducts($products);
    }
    return $this->getData('allow_products');
}

Replace with this

public function getAllowProducts()
{
    if (!$this->hasAllowProducts()) {
        $products = array();
        $skipSaleableCheck = Mage::helper('catalog/product')->getSkipSaleableCheck();
        $allProducts = $this->getProduct()->getTypeInstance(true)
            ->getUsedProducts(null, $this->getProduct());
        foreach ($allProducts as $product) {
            $products[] = $product;
        }
        $this->setAllowProducts($products);
    }
    return $this->getData('allow_products');
}

Note: Don't Edit in Core files. Make rewrite or copy the folder structure in to local code pool.

Cheers.

|improve this answer|||||
  • Thanks. If I edit core file it works. Can you help me with overriding it? I created the file app/code/local/SpartakusMd/CustomProductImporter/Catalog/Block/Product/View/Type/Configurable.php with the class class SpartakusMd_CustomProductImporter_Catalog_Block_Product_View_Type_Configurable extends Mage_Catalog_Block_Product_View_Type_Configurable, but it doesn't seem to override it. What is wrong? – Marin Bînzari May 8 '14 at 7:44
  • Oooh, I forgot about config.xml. What shoud I insert there? – Marin Bînzari May 8 '14 at 7:47
  • @SpartakusMd there is another way. You can copy the Same folder structure in local. like local/Mage/Catalog/Block/Product/View/Type/Configurable.php – MeenakshiSundaram R May 8 '14 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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