diff --git a/vendor/magento/module-catalog/Model/ResourceModel/GetProductTypeById.php b/vendor/magento/module-catalog/Model/ResourceModel/GetProductTypeById.php
new file mode 100644
index 000000000000..e7615c544530
--- /dev/null
+++ b/vendor/magento/module-catalog/Model/ResourceModel/GetProductTypeById.php
@@ -0,0 +1,52 @@
+resource = $resource;
+ }
+
+ /**
+ * Retrieve product type by its product ID
+ *
+ * @param int $productId
+ * @return string
+ */
+ public function execute(int $productId)
+ {
+ $connection = $this->resource->getConnection();
+ $productTable = $this->resource->getTableName('catalog_product_entity');
+
+ $select = $connection->select()
+ ->from(
+ $productTable,
+ ProductInterface::TYPE_ID
+ )->where('entity_id = ?', $productId);
+
+ $result = $connection->fetchOne($select);
+ return $result ?: '';
+ }
+}
diff --git a/vendor/magento/module-configurable-product/Model/Inventory/ChangeParentStockStatus.php b/vendor/magento/module-configurable-product/Model/Inventory/ChangeParentStockStatus.php
index 9bb4659b31db..4ad15ea905f0 100644
--- a/vendor/magento/module-configurable-product/Model/Inventory/ChangeParentStockStatus.php
+++ b/vendor/magento/module-configurable-product/Model/Inventory/ChangeParentStockStatus.php
@@ -106,6 +106,7 @@ private function processStockForParent(int $productId): void
if ($this->isNeedToUpdateParent($parentStockItem, $childrenIsInStock)) {
$parentStockItem->setIsInStock($childrenIsInStock);
$parentStockItem->setStockStatusChangedAuto(1);
+ $parentStockItem->setStockStatusChangedAutomaticallyFlag(true);
$this->stockItemRepository->save($parentStockItem);
}
}
diff --git a/vendor/magento/module-configurable-product/Model/Plugin/UpdateStockChangedAuto.php b/vendor/magento/module-configurable-product/Model/Plugin/UpdateStockChangedAuto.php
new file mode 100644
index 000000000000..c5a0cd5eae7f
--- /dev/null
+++ b/vendor/magento/module-configurable-product/Model/Plugin/UpdateStockChangedAuto.php
@@ -0,0 +1,49 @@
+getProductTypeById = $getProductTypeById;
+ }
+
+ /**
+ * Updates stock_status_changed_auto for configurable product
+ *
+ * @param ItemResourceModel $subject
+ * @param StockItem $stockItem
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
+ public function beforeSave(ItemResourceModel $subject, StockItem $stockItem): void
+ {
+ if (!$stockItem->getIsInStock() &&
+ !$stockItem->hasStockStatusChangedAutomaticallyFlag() &&
+ $this->getProductTypeById->execute($stockItem->getProductId()) == Configurable::TYPE_CODE
+ ) {
+ $stockItem->setStockStatusChangedAuto(0);
+ }
+ }
+}
diff --git a/vendor/magento/module-configurable-product/etc/di.xml b/vendor/magento/module-configurable-product/etc/di.xml
index 270e8ec74609..16e3aaafc9cb 100644
--- a/vendor/magento/module-configurable-product/etc/di.xml
+++ b/vendor/magento/module-configurable-product/etc/di.xml
@@ -280,4 +280,7 @@
Magento\Framework\Serialize\Serializer\Json
+
+
+