Magento easy way to show out of stock in configurable product (greyed out)

Warning, using setSkipSaleableCheck(true) appears to have an additional effect of showing disabled products in the dropdown.

The function which is affected by this setting is in Mage_Catalog_Block_Product_View_Type_Configurable:

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');
}

if ($product->isSaleable() || $skipSaleableCheck) will therefore always be true

I am yet to dig through the isSaleable() function to determine exactly where this occurs (maybe someone can confirm) but my guess is that it includes a check against the products status which is missed if the skipSaleableCheck is set to true.


The "code" solution:
Create your own module, and in the config.xml file of the module add these 2 events inside the <frontend> tag:

    <events>
        <controller_action_layout_render_before_catalog_product_view>
            <observers>
                <[namespace]_[module]>
                    <class>[module]/observer</class>
                    <method>showOutOfStock</method>
                </[namespace]_[module]>
            </observers>
        </controller_action_layout_render_before_catalog_product_view>
        <controller_action_layout_render_before_checkout_cart_configure>
            <observers>
                <[namespace]_[module]>
                    <class>[module]/observer</class>
                    <method>showOutOfStock</method>
                </[namespace]_[module]>
            </observers>
        </controller_action_layout_render_before_checkout_cart_configure>
    </events>

Now create an observer inside app/code/local/[Namespace]/[Module]/Model/Observer.php

class [Namespace]_[Module]_Model_Observer {
    public function showOutOfStock($observer){
        Mage::helper('catalog/product')->setSkipSaleableCheck(true);
    }
}

The extension solution
You can use this extension. Among other features, it allows you to show out of stock configuration for the configurable product.
It can also replace the standard dropdowns with labels and it adds an overlay over the out of stock combinations. Like this (see medium option)

out of stock


@Marius's answer was correct until version 1.9.3, since then the function getAllowProducts() at app/code/core/Mage/Catalog/Block/Product/View/Type/Configurable.php has added the verification of catalog inventory on admin on either show or not out of stock products.

Here's the diff:

    /*
     * Get Allowed Products
     *
     * @return array
     */
    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) {
+                if ($product->isSaleable()
+                    || $skipSaleableCheck
+                    || (!$product->getStockItem()->getIsInStock()
+                        && Mage::helper('cataloginventory')->isShowOutOfStock())) {
                    $products[] = $product;
                }
            }
            $this->setAllowProducts($products);
        }
        return $this->getData('allow_products');
    }

You can also check from: https://github.com/OpenMage/magento-mirror/commit/d48bebc211cc216aaf78bdf25d7f0b0143d6333b#diff-0cbcafcade005d8e84c0377c83a67f6c

So, if you're using the 1.9.3 version all you need to do is select Yes on System > Configuration > Catalog > Inventory > Show Out Of Stock Products.