Skip to content

Commit 6fd5921

Browse files
author
Serhiy Shkolyarenko
committed
MAGETWO-39117: Updating qty that exceeds the qty in stock for registered customer by API should return error
fixed item quantity check
1 parent c67bdfd commit 6fd5921

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

app/code/Magento/Quote/Model/Quote/Item/CartItemPersister.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ public function save(CartInterface $quote, CartItemInterface $item)
7272
$item = $quote->updateItem($itemId, $buyRequestData);
7373
} else {
7474
$currentItem->setQty($qty);
75+
if (!empty($currentItem->getErrorInfos())) {
76+
$errors = $currentItem->getErrorInfos();
77+
/** @var \Magento\Framework\Message\MessageInterface $error */
78+
$errorData = array_shift($errors);
79+
throw new CouldNotSaveException($errorData['message']);
80+
}
7581
}
7682
} else {
7783
/** add new item to shopping cart */

0 commit comments

Comments
 (0)