How to Show Magento 2 Out of Stock Associated Products in Configurable Products Dropdown

How to Show Magento 2 Out of Stock Associated Products in Configurable Products Dropdown

A configurable product seems like a single product with drop-down lists of options for each variation. Each option is a separate simple product with a unique SKU.

The admin can track the inventory of each product variation for configurable products. However, the default Magento 2 does not bifurcate the products display in frontend based on its availability.

For configurable products, what if a customer adds the option that is not in stock and he is taken to the cart only to find out that he can’t make the purchase now! Isn’t it the example of bad shopping experience!

The solution is to show Magento 2 Out of Stock associated products in configurable products dropdown. When associated products of the configurable products are shown under the separate dropdown along with their stock status, it makes it easy for customers to decide which products to add in cart and for which product, to subscribe for the alert notification when back in stock. To enable the notification facility, you can try the Magento 2 Out of Stock Notification extension!

To display the separate dropdown for out of stock associated products in configurable products, follow this method:

Method to Show Magento 2 Out of Stock Associated Products in Configurable Products Dropdown:

  1. Create registration.php file in app\code\[Vendor]\[Namespace]\
  2. Create module.xml file in app\code\[Vendor]\[Namespace]\etc
  3. Create catalog_product_view_type_configurable.xml file in app\code\[Vendor]\[Namespace]\view\frontend\layout    
  4. Create child-drop-down.phtml file in app\code\[Vendor]\[Namespace]\view\frontend\templates\product

  5. Create Data.php file in app\code\[Vendor]\[Namespace]\Helper

The above code is compatible with Meetanshi’s Magento 2 Out of Stock Notification extension.

The result is displayed in the frontend:

How to Show Magento 2 Out of Stock Associated Products in Configurable Products Dropdown

Using this method, the customers can know the stock status of their desired configurable associated product and hence accordingly make the purchase or decide to wait!

Use the Comments section below to get any help with the implementation of the method.

Thank you.

Get Weekly Updates

Never miss Magento tips, tricks, tutorials, and news.

Thank you for subscribing.

Something went wrong.

5
(based on 13 Reviews)

Sanjay is a co-founder at Meetanshi. He is a Certified Magento Developer who loves creating Magento E-commerce solutions. Owing to his contributions in Magento Forums and posting solutions, he is among the top 50 contributors of the Magento community in 2019. When he is not engrossed with anything related to Magento, he loves to play cricket.

8 comments On How to Show Magento 2 Out of Stock Associated Products in Configurable Products Dropdown

Leave a reply:

Your email address will not be published.