-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configurable products marked out of stock incorrectly #3350
Comments
Hi @aligent-lturner. Thank you for your report. Add a comment to assign the issue:
|
I have the same problem. Any temporal solution available? Thanks |
HI @aligent-lturner , We are also facing similar issue, when we installed either 2.4.4 CE/EE the MSI modules will be installed as part Magento Core application through composer and enabled by default. When MSI modules are enabled the configurable parent product stock status are not updating correctly and always stays in Out Of Stock (OOS) once the stock status changed from Is In stock to OOS (either by updating child product stock status or parent). If we disable MSI Inventory modules then configurable parent product stock status updating as expected. I already reported this below, so please refer for information. Expecting, someone going to address this ASAP as it is Major bug for all vendors. Please let me know if anyone needs additional information. |
Hello, I have a temporal solution that is working for me. We are override \Magento\ConfigurableProduct\Model\Inventory\ChangeParentStockStatus The problem is the variable $childrenIsInStock is initialized a false and then never change the value. We are calculated the value of this variable with the sum of sources quantities. This is incorrect if you use stock for websites, but this is a fastest solution for us to resolve the problem in production environment. This is my function processStockForParent
|
Is this related to https://support.magento.com/hc/en-us/articles/4428085214093-MDVA-42584-Stock-status-of-configurable-product-not-updated-automatically? It might not be as the patch mentioned the issues is via simple product being updated via API or import. |
Hi, has anyone looking in to this issue? |
solved in quality patch: MDVA-41061-V4 and ACSD-45488 https://devdocs.magento.com/quality-patches/tool.html#patch-grid |
Seems like it wasn't solved. Still experiencing an issue with it. Configurable goes OOS |
Experienced the same. Below patches didn't solve the issue. Any recent update? |
After shipment, the configurable product goes OOS just because of https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/ConfigurableProduct/Model/Inventory/ChangeParentStockStatus.php#L100. 2.4.4 introduced with https://github.com/magento/inventory/blob/e08a47c3501de2cbff42b3ac05058ce15d620e75/InventoryConfigurableProduct/Plugin/InventoryApi/UpdateParentStockStatusInLegacyStockPlugin.php. When you have more than one source, cataloginventory_stock_item table stock status never update and your entire things will broken. Made adjustment with MSI like @IvanVizcaino did. |
Hello there, I am facing this issue too, now I think the problem stays in this file "
The IndexStructure::IS_SALABLE => 'IF(inventory_stock_item.is_in_stock = 0, 0, MAX(stock.is_salable))' condition seem wrong if the stock leagagy for configurable =0 therefore the is_salable for "inventory_stock_x" table wrong too. Can we change to "IndexStructure::IS_SALABLE => 'IF(MAX(stock.is_salable),MAX(stock.is_salable),inventory_stock_item.is_in_stock)'," instead ? |
Any update here? We are experiencing in 2.4.5p-1 still |
Hello, I got the same issue on my side. I temporary created this patch : |
That patch seems to be working perfectly on 2.4.4 as well. Thanks! |
This issue also exists for bundled products |
And grouped products.. |
@RonanCapitaine are you able to raise a PR with your changes so that Magento / Adobe can review this and merge it in for the next release? That would help us all! Really appreciate your efforts. |
It works fine with Magento 2.4.5-p2! Thank you very much! I note that ACSD-45488 unfortunately did not fix it. |
Hi Ronan, I have the same issue on the Magento 2.4.6-p5. But this patch can't apply on the M2.4.6-p5 because this file doesn't exist on this Magento version. Please let me know if you have any solution for the last Magento version. Thanks |
For those still experiencing issues where configurable products stock status fails to update when child products come back in-stock. --- a/vendor/magento/module-configurable-product/Model/Inventory/ChangeParentStockStatus.php 2024-06-27 11:54:34.515474442 +0100
+++ b/vendor/magento/module-configurable-product/Model/Inventory/ChangeParentStockStatus.php 2024-06-27 11:56:33.263253341 +0100
@@ -1,8 +1,10 @@
<?php
+
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
declare(strict_types=1);
namespace Magento\ConfigurableProduct\Model\Inventory;
@@ -83,27 +85,38 @@
$criteria->setProductsFilter($productId);
$stockItemCollection = $this->stockItemRepository->getList($criteria);
+
+ /** @var \Magento\CatalogInventory\Model\Stock\Item[] */
$allItems = $stockItemCollection->getItems();
if (empty($allItems)) {
+
return;
}
+
$parentStockItem = array_shift($allItems);
$childrenIds = $this->configurableType->getChildrenIds($productId);
+ $childrenIds = (is_array($childrenIds) && !empty($childrenIds) && is_array($childrenIds[0]))
+ ? $childrenIds[0]
+ : $childrenIds;
+
$criteria->setProductsFilter($childrenIds);
$stockItemCollection = $this->stockItemRepository->getList($criteria);
- $allItems = $stockItemCollection->getItems();
+ /** @var \Magento\CatalogInventory\Model\Stock\Item[] */
+ $allItems = $stockItemCollection->getItems();
$childrenIsInStock = false;
-
foreach ($allItems as $childItem) {
+
if ($childItem->getIsInStock() === true) {
+
$childrenIsInStock = true;
break;
}
}
if ($this->isNeedToUpdateParent($parentStockItem, $childrenIsInStock)) {
+
$parentStockItem->setIsInStock($childrenIsInStock);
$parentStockItem->setStockStatusChangedAuto(1);
$parentStockItem->setStockStatusChangedAutomaticallyFlag(true);
@@ -122,7 +135,7 @@
StockItemInterface $parentStockItem,
bool $childrenIsInStock
): bool {
- return $parentStockItem->getIsInStock() !== $childrenIsInStock &&
- ($childrenIsInStock === false || $parentStockItem->getStockStatusChangedAuto());
+
+ return $parentStockItem->getIsInStock() !== $childrenIsInStock;
}
} |
Patch ACSD-48910 fixed this issue for me. It works for Magento 2.4.5-x. (https://experienceleague.adobe.com/en/docs/commerce-knowledge-base/kb/support-tools/patches/v1-1-42/acsd-48910-bundle-product-assigned-to-multiple-sources-out-of-stock) |
This also seems to work on 2.4.7-p3 |
Preconditions (*)
default
sourceSteps to reproduce (*)
Expected result (*)
Actual result (*)
Additional information
I believe this is caused by https://github.com/magento/inventory/blob/e08a47c3501de2cbff42b3ac05058ce15d620e75/InventoryConfigurableProduct/Plugin/InventoryApi/UpdateParentStockStatusInLegacyStockPlugin.php
This plugin updates the status of configurable products based on the stock status of their simple components, but it does not take the inventory setup into account at all. In our case, the default source has not been updated at all, yet the result is that the
cataloginventory_stock_item
table is updated for the configurable product. As a result of this, the inventory stock indexer takes this changed value into account and subsequently marks the configurable as not salable for any non-default stocks.There is an additional plugin https://github.com/magento/inventory/blob/e08a47c3501de2cbff42b3ac05058ce15d620e75/InventoryConfigurableProduct/Plugin/InventoryApi/UpdateConfigurableProductParentStockStatus.php that was added later that appears to be for much the same purpose, but with additional checks that single source mode and a single store are being used.
The text was updated successfully, but these errors were encountered: