I'm facing issue that configurable products showing out of stock associated products even if the backend setting "Display Out of Stock Products" at Configuration->Catalog->Inventory->Stock Options is set to "No".
Does anyone knows the fix for this?
associated-productsconfigurable-productmagento2out-of-stockstock-status
I'm facing issue that configurable products showing out of stock associated products even if the backend setting "Display Out of Stock Products" at Configuration->Catalog->Inventory->Stock Options is set to "No".
Does anyone knows the fix for this?
Best Answer
I've fixed this issue by overriding the below file in our custom module: \Magento\ConfigurableProduct\Helper\Data.php
Below are the complete steps:
1) Add below statement in your module's di.xml
2) Create a file Data.php at YOUR_COMPANY\MODULE_NAME\Helper\ConfigurableProduct and put below code in it
I've added condition for website_id as I want to hide out of stock options for 2nd website only. You can remove that condition.
Flush the cache and check any configurable product having out of stock associated products in it.
Thanks!