Skip to content

Commit c5e0268

Browse files
committed
ACP2E-368: Issue when adding multiple items in addProductsToCart graphQL mutation
1 parent 7959603 commit c5e0268

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

app/code/Magento/Quote/Model/Cart/AddProductsToCart.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ public function execute(string $maskedCartId, array $cartItems): AddProductsToCa
118118
if (count($this->errors) !== 0) {
119119
/* Revert changes introduced by add to cart processes in case of an error */
120120
$cart->getItemsCollection()->clear();
121+
} else {
122+
$this->cartRepository->save($cart);
121123
}
122124

123125
return $this->prepareErrorOutput($cart);
@@ -153,7 +155,6 @@ private function addItemToCart(CartInterface $cart, Data\CartItem $cartItem, int
153155

154156
try {
155157
$result = $cart->addProduct($product, $this->requestBuilder->build($cartItem));
156-
$this->cartRepository->save($cart);
157158
} catch (\Throwable $e) {
158159
$this->addError(
159160
__($e->getMessage())->render(),

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,11 +1711,6 @@ public function addProduct(
17111711
throw new \Magento\Framework\Exception\LocalizedException(__(implode("\n", $errors)));
17121712
}
17131713

1714-
if ($items) {
1715-
$this->setTotalsCollectedFlag(false);
1716-
$this->_addresses = null;
1717-
}
1718-
17191714
$this->_eventManager->dispatch('sales_quote_product_add_after', ['items' => $items]);
17201715
return $parentItem;
17211716
}

0 commit comments

Comments
 (0)