I am facing an issue with Magento2 and I am not sure whether it's a bug or not. I want to show Out of Stock Assosiated Products in the Configurable Product Dropdown.
In the admin settings, Stores -> Configuration -> Catalog -> Inventory -> Display out of stock products, this is already set to "Yes" but no luck.
I have tried several modules with integrating plugins and did a lot of research on this but could not find any solution for this.
Lets take an example - I have a Configurable Product with Child products Size - S , M , L and for instance L is out of stock. So currently I am able to see S and M in the dropdown options for my configurable product.
I want to see all the 3 Child products with the mark of "Out of Stock" like L - Out of Stock or something like that.
sorry for the late reply. I was really busy with different projects.
So for this, i used 1 module and did customized that based on my requirements. I am providing you all the files and folders so anyone who needs this, can upload the files.
Created a module - Jworks/ConfigurableProduct so the folder structure will be /app/code/Jworks/ConfigurableProduct
Create a file app/code/Jworks/ConfigurableProduct/registration.php and enter below code -
Create a file app/code/Jworks/ConfigurableProduct/composer.json and enter below code -
Create a file app/code/Jworks/ConfigurableProduct/etc/module.xml and enter below code -
Create a file app/code/Jworks/ConfigurableProduct/etc/di.xml and enter below code -
Create a file app/code/Jworks/ConfigurableProduct/etc/frontend/di.xml and enter below code -
Create a file app/code/Jworks/ConfigurableProduct/Plugin/Model/AttributeOptionProvider.php and enter below code -
Create a file app/code/Jworks/ConfigurableProduct/Plugin/Model/ResourceModel/Attribute/InStockOptionSelectBuilder.php and enter below code -
Create a file app/code/Jworks/ConfigurableProduct/Model/Rewrite/ConfigurableAttributeData.php and enter below code -
Create a file app/code/Jworks/ConfigurableProduct/Model/ConfigurableProduct/Block/Product/View/Type/Configurable/Plugin.php and enter below code -
And after all these, you can run all the commands for installing the Magento2 extension.
I hope anybody can get help with this.
open the file vendor\magento\module-catalog\Helper\Product.php
change
to