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.

  • have you using any color swatches custom module? – Abdul Jun 14 '16 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. – mr.hironobu Jun 14 '16 at 10:51
  • Does it is custom attribute or configurable product ? – samumaretiya Jun 14 '16 at 11:41
  • Can you share link , then we also see how are you develop without third party module ? Superman .. – Pratik Kamani Jun 14 '16 at 11:52
  • See this link: stackoverflow.com/questions/10798049/… I hope it help you – André Tanaka Sep 1 '16 at 14:20
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.

| improve this answer | |
  • how can we achieve the same in m2? – jafar pinjar Dec 19 '18 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.

| improve this answer | |
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.

| improve this answer | |
  • 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 – Wasim Akram Jul 30 '16 at 13:31

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.