Configurable product should display all simple products, also the simple products which are out of stock.

For example an item has the sizes S, M, L, XL. And M is out of stock.

At this moment it only shows S L XL.

I need Magento to show also the size M (with an "out of stock" css class added to it).

How can I fix this for Magento 2.3(!) ?

  • 2
    Go to admin > Stores > configuration > Catalog > Inventory > Stock Options Set Display "Out of Stock Products" to YES Commented Mar 20, 2019 at 10:42
  • That does not work.
    – Bernd
    Commented Mar 20, 2019 at 11:09
  • did you reindex / recache the website after enabling it Commented Mar 20, 2019 at 11:13
  • Yes, and it is a known issue (github.com/magento/magento2/issues/15047). So I'm curious how it can work for you? Do you maybe have a preview url, where you got it working? Because I think you don't understand what the problem is.
    – Bernd
    Commented Mar 20, 2019 at 12:14
  • Have you tried this (magento.stackexchange.com/questions/216373/…) solution? Commented Mar 26, 2019 at 11:28

2 Answers 2


The above one is a known issue for Magento and can be solved partially by installing the below extension.


Reference for the Issue can be found at Magento Issue 10454


To make visible swatshes that related to out of stock products try to make such changes

  1. Create your own module
  2. Create etc/di.xml file

add there code

<type name="Magento\ConfigurableProduct\Helper\Data">
    <plugin name="VendorName_ModuleName_Plugin_Magento_ConfigurableProduct_Helper_Data"
            type="VendorName\ModuleName\Plugin\Magento\ConfigurableProduct\Helper\Data" sortOrder="10" disabled="false"/>
  1. Create Plugin Class VendorName\ModuleName\Plugin\Magento\ConfigurableProduct\Helper\Data


namespace VendorName\ModuleName\Plugin\Magento\ConfigurableProduct\Helper;

use Magento\Framework\App\Config\ScopeConfigInterface;

* Plugin for making visible swatches that related to  out of stock products
* depend on the setting admin->Stores->configuration->Catalog->Inventory->Stock Options->Out of Stock Products
class Data
    const SHOW_OUT_OF_STOCK_CONFIG_PATH = "cataloginventory/options/show_out_of_stock";
    protected ScopeConfigInterface $scopeConfig;

    *@param ScopeConfigInterface $scopeConfig
    public function __construct(ScopeConfigInterface $scopeConfig)
        $this->scopeConfig = $scopeConfig;

     * @param \Magento\ConfigurableProduct\Helper\Data $subject
     * @param \Closure $proceed
     * @param $currentProduct
     * @param $allowedProducts
     * @return array
public function aroundGetOptions(
    \Magento\ConfigurableProduct\Helper\Data $subject,
    \Closure                                 $proceed,

) {
    $result = $proceed($currentProduct, $allowedProducts);

    $show_out_of_stock = $this->scopeConfig->getValue(self::SHOW_OUT_OF_STOCK_CONFIG_PATH,
    $options = [];
    $allowAttributes = $subject->getAllowAttributes($currentProduct);

    foreach ($allowedProducts as $product) {
        $productId = $product->getId();
        foreach ($allowAttributes as $attribute) {
            $productAttribute = $attribute->getProductAttribute();
            $productAttributeId = $productAttribute->getId();
            $attributeValue = $product->getData($productAttribute->getAttributeCode());
            if ($show_out_of_stock || $product->isSalable()) {
                $options[$productAttributeId][$attributeValue][] = $productId;
            $options['index'][$productId][$productAttributeId] = $attributeValue;

    return $options;

Your Answer

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

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