Skip to content

Commit 73c3f2b

Browse files
author
Oleksandr Iegorov
committed
MC-42652: GraphQL - Expected behavior of add product to cart when SKU already exists
1 parent 0d49f6c commit 73c3f2b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

app/code/Magento/QuoteGraphQl/Model/Cart/AddSimpleProductToCart.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,16 @@ private function addProductToCartWithConcurrency(Quote $cart, Product $product,
199199
}
200200
break;
201201
}
202+
203+
$itemsToUpdate = [];
204+
foreach ($cart->getItems() as $itemToUpdate) {
205+
if ($itemToUpdate->getItemId() === $item->getItemId()) {
206+
$itemsToUpdate[] = $item;
207+
} else {
208+
$itemsToUpdate[] = $itemToUpdate;
209+
}
210+
}
211+
$cart->setItems($itemsToUpdate);
202212
}
203213
if (!empty($errors)) {
204214
throw new LocalizedException(__(implode("\n", $errors)));

0 commit comments

Comments
 (0)