2

I would need help regarding the out of stock and color/size display function on Magento based website.

I show the items on my website, even after they went out of stock.

But the problem is that after an item goes out of stock, the color and size are not visible anymore. And I would like to show the color and size available at the origin for the item, even when out of stock. Like on this image, I would like to show them in the red area. enter image description here

So can somebody help me with this?

Thank you.

5
  • have you using any color swatches custom module?
    – Abdul
    Jun 14, 2016 at 10:44
  • By custom module do you mean third party extension? If yes, no I do not use it. I only use the default Magento. Jun 14, 2016 at 10:51
  • Does it is custom attribute or configurable product ? Jun 14, 2016 at 11:41
  • Can you share link , then we also see how are you develop without third party module ? Superman .. Jun 14, 2016 at 11:52
  • See this link: stackoverflow.com/questions/10798049/… I hope it help you Sep 1, 2016 at 14:20

3 Answers 3

1

You can write an observer for the event catalog_controller_product_init.
Add this to the config.xml file in one of your modules inside the <frontend> tag.

<events>
    <catalog_controller_product_init>
        <observers>
            <[namespace]_[module]>
                <class>[module]/observer</class>
                <method>showStock</method>
            </[namespace]_[module]>
        </observers>
    </catalog_controller_product_init>
</events>

then create the file [Namespace]/[Module]/Model/Observer.php

<?php 
class [Namespace]_[Module]_Model_Observer
{
    public function showStock(Varien_Event_Observer $observer)
    {
        /** @var Mage_Catalog_Model_Product $product */
        $product = $observer->getEvent()->getProduct();
        if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
            Mage::helper('catalog/product')->setSkipSaleableCheck(true);
        }
        return $this;
    }
}

The downside of this is that the configurable product will appear as in stock in the product even if all the simple products are out of stock.

1
  • how can we achieve the same in m2? Dec 19, 2018 at 9:36
0

This is how Magento works. If some of your associated products go out of stock, attribute options do not display at the frontend. If you set swatches for configurable products, you will have the same - once some simple runs out of stock, swatch will not display for it at the frontend.

The only suggestion is to use custom options, though you will not be able to track product stock.

0

I think you should use configurable product using color attribute and size attribute and make configurable swatches to "Yes", then only it will show. I did to show color and sizes in configurable product and it was working fine. You should use configurable swatches. It will definitely work for you try find it on google.

1
  • I think you should use configurable product using color attribute and size attribute and make configurable swatches to "Yes", then only it will show. I did to show color and sizes in configurable product and it was working fine. You should use configurable swatches Jul 30, 2016 at 13:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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