Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit c608b02

Browse files
author
Oleksii Gorbulin
committed
19482-Increase-product-quantity-with-disabled-Manage-Stock-when-place-order-is-failed
Magento2:#19482 Increase product quantity with disabled Manage Stock when place order is failed
1 parent 2b27bc0 commit c608b02

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

app/code/Magento/CatalogInventory/Model/StockManagement.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,17 @@ public function revertProductsSale($items, $websiteId = null)
150150
//if (!$websiteId) {
151151
$websiteId = $this->stockConfiguration->getDefaultScopeId();
152152
//}
153-
$this->qtyCounter->correctItemsQty($items, $websiteId, '+');
153+
$revertItems = [];
154+
foreach ($items as $productId => $qty) {
155+
$stockItem = $this->stockRegistryProvider->getStockItem($productId, $websiteId);
156+
$canSubtractQty = $stockItem->getItemId() && $this->canSubtractQty($stockItem);
157+
if (!$canSubtractQty || !$this->stockConfiguration->isQty($stockItem->getTypeId())) {
158+
continue;
159+
}
160+
$revertItems[$productId] = $qty;
161+
}
162+
$this->qtyCounter->correctItemsQty($revertItems, $websiteId, '+');
163+
154164
return true;
155165
}
156166

0 commit comments

Comments
 (0)