Skip to content

Commit

Permalink
19482-Increase-product-quantity-with-disabled-Manage-Stock-when-place…
Browse files Browse the repository at this point in the history
…-order-is-failed

Magento2:#19482 Increase product quantity with disabled Manage Stock when place order is failed
  • Loading branch information
Oleksii Gorbulin committed Dec 27, 2018
1 parent 2b27bc0 commit c608b02
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/code/Magento/CatalogInventory/Model/StockManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,17 @@ public function revertProductsSale($items, $websiteId = null)
//if (!$websiteId) {
$websiteId = $this->stockConfiguration->getDefaultScopeId();
//}
$this->qtyCounter->correctItemsQty($items, $websiteId, '+');
$revertItems = [];
foreach ($items as $productId => $qty) {
$stockItem = $this->stockRegistryProvider->getStockItem($productId, $websiteId);
$canSubtractQty = $stockItem->getItemId() && $this->canSubtractQty($stockItem);
if (!$canSubtractQty || !$this->stockConfiguration->isQty($stockItem->getTypeId())) {
continue;
}
$revertItems[$productId] = $qty;
}
$this->qtyCounter->correctItemsQty($revertItems, $websiteId, '+');

return true;
}

Expand Down

0 comments on commit c608b02

Please sign in to comment.