This is my hotfix.
Create extension Lexim_InventoryConfigurableProduct
etc/di.xml
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Inventory\Model\SourceItem\Command\DecrementSourceItemQty"> <plugin name="update_parent_configurable_product_stock_status_in_legacy_stock" disabled="true"/> <plugin name="update_parent_configurable_product_stock_status_in_legacy_stock_fix" type="Lexim\InventoryConfigurableProduct\Plugin\InventoryApi\UpdateParentStockStatusInLegacyStockPlugin"/> </type> </config>
Plugin\InventoryApi\UpdateParentStockStatusInLegacyStockPlugin.php
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Lexim\InventoryConfigurableProduct\Plugin\InventoryApi; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Inventory\Model\SourceItem\Command\DecrementSourceItemQty; use Magento\InventoryApi\Api\Data\SourceItemInterface; use Magento\InventoryCatalogApi\Api\DefaultSourceProviderInterface; use Magento\InventoryCatalogApi\Model\GetProductIdsBySkusInterface; use Magento\ConfigurableProduct\Model\Inventory\ChangeParentStockStatus; /** * Apply a fix for update configurable product stock status in legacy stock * after decrement quantity of child stock item */ class UpdateParentStockStatusInLegacyStockPlugin { /** * @var DefaultSourceProviderInterface */ private $defaultSourceProvider; /** * @var ChangeParentStockStatus */ private $changeParentStockStatus; /** * @var GetProductIdsBySkusInterface */ private $getProductIdsBySkus; /** * @param DefaultSourceProviderInterface $defaultSourceProvider * @param GetProductIdsBySkusInterface $getProductIdsBySkus * @param ChangeParentStockStatus $changeParentStockStatus */ public function __construct( DefaultSourceProviderInterface $defaultSourceProvider, GetProductIdsBySkusInterface $getProductIdsBySkus, ChangeParentStockStatus $changeParentStockStatus ) { $this->defaultSourceProvider = $defaultSourceProvider; $this->getProductIdsBySkus = $getProductIdsBySkus; $this->changeParentStockStatus = $changeParentStockStatus; } /** * Make configurable product out of stock if all its children out of stock * * @param DecrementSourceItemQty $subject * @param void $result * @param SourceItemInterface[] $sourceItemDecrementData * @return void * @throws NoSuchEntityException */ public function afterExecute(DecrementSourceItemQty $subject, $result, array $sourceItemDecrementData): void { $productIds = []; $sourceItems = array_column($sourceItemDecrementData, 'source_item'); /** @var SourceItemInterface $sourceItem */ foreach ($sourceItems as $sourceItem) { $sku = $sourceItem->getSku(); if ($sourceItem->getSourceCode() === $this->defaultSourceProvider->getCode() && $productId = ($this->getProductIdsBySkus->execute([$sku])[$sku] ?? null) ) { $productIds[] = (int) $productId; } } if ($productIds) { $this->changeParentStockStatus->execute($productIds); } } }
registration.php
<?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'Lexim_InventoryConfigurableProduct', __DIR__ );
module.xml
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <module name="Lexim_InventoryConfigurableProduct" setup_version="1.0.0" /> </config>
I hope you can fix the error!