Skip to content

Commit 1cca857

Browse files
authored
Change commit to rollBack on fail
I suppose we should rollback transaction before exception. We are in the loop and we should not commit partial result on error or we should not use transaction at all.
1 parent 5a615bb commit 1cca857

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function registerProductsSale($items, $websiteId = null)
102102
if (!$stockItem->hasAdminArea()
103103
&& !$this->stockState->checkQty($productId, $orderedQty, $stockItem->getWebsiteId())
104104
) {
105-
$this->getResource()->commit();
105+
$this->getResource()->rollBack();
106106
throw new \Magento\Framework\Exception\LocalizedException(
107107
__('Not all of your products are available in the requested quantity.')
108108
);
@@ -180,7 +180,7 @@ protected function getProductType($productId)
180180
}
181181

182182
/**
183-
* @return Stock
183+
* @return ResourceStock
184184
*/
185185
protected function getResource()
186186
{

0 commit comments

Comments
 (0)