product – How to Display Out of Stock Products on Site

ce-1.7.0.2configurable-productproductproduct-attributestock

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.

Best Answer

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.