How to show out of stock configurable options with Magento

Why Magento won’t allow you to show out of stock options in configurable products is beyond me, thankfuly nyah, on the Magento forums was kind enough to post a “quick-fix” for this delima, first edit:

:arrow: app/code/core/Mage/Catalog/Block/Product/View/Configurable.php

locate the getAllowProducts() function…

1
2
3
4
5
6
7
8
9
10
11
12
13
14
public function getAllowProducts()
    {
        if (!$this->hasAllowProducts()) {
            $products = array();
            $allProducts = $this->getProduct()->getTypeInstance()->getUsedProducts();
            foreach ($allProducts as $product) {
                if ($product->isSaleable()) {
                    $products[] = $product;
                }
            }
            $this->setAllowProducts($products);
        }
        return $this->getData('allow_products');
    }

and replace or comment out the existing method with:

1
2
3
4
5
public function getAllowProducts() {
        $allProducts = $this->getProduct()->getTypeInstance()->getUsedProducts();
        $this->setAllowProducts($allProducts);
        return $this->getData('allow_products');
    }

Looking at the above fix basically all products in the configurable product are displayed regardless of their isSaleable() state. Which I’m assuming a better solution would be to modify it instead in case of other instances not just out of stock.

This won’t disable the product out the option but if a user attempts to order it will get an out of stock message. Its not perfect but serves the purpose until Magento can possibly make a more permanent solution.

:!: Be aware this modifies the Core code of magento and its highly recommended that you make a backup of the Configurable.php file before modifying its contents.

:arrow: Magento – Show out of stock configurable options – as disabled select option – ‘How do I’ Questions – eCommerce Software for Growth.

Possibly Related Posts:



2 Responses to “How to show out of stock configurable options with Magento”

Leave a Reply

:D :-) :( :o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: