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 authored and Amol Chaudhari committed Jan 27, 2019
1 parent 78182ac commit abddea8
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 @@ -148,7 +148,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 abddea8

Please sign in to comment.