Skip to content

Commit f83c206

Browse files
author
Oleksandr Iegorov
committed
MC-42652: GraphQL - Expected behavior of add product to cart when SKU already exists
1 parent 2c550fb commit f83c206

File tree

1 file changed

+1
-24
lines changed

1 file changed

+1
-24
lines changed

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

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1111
use Magento\Quote\Api\CartRepositoryInterface;
1212
use Magento\Quote\Model\Quote;
13-
use Magento\Framework\Lock\LockManagerInterface;
1413

1514
/**
1615
* Adding products to cart using GraphQL
@@ -27,24 +26,16 @@ class AddProductsToCart
2726
*/
2827
private $addProductToCart;
2928

30-
/**
31-
* @var LockManagerInterface
32-
*/
33-
private $lockManager;
34-
3529
/**
3630
* @param CartRepositoryInterface $cartRepository
3731
* @param AddSimpleProductToCart $addProductToCart
38-
* @param LockManagerInterface $lockManager
3932
*/
4033
public function __construct(
4134
CartRepositoryInterface $cartRepository,
42-
AddSimpleProductToCart $addProductToCart,
43-
LockManagerInterface $lockManager
35+
AddSimpleProductToCart $addProductToCart
4436
) {
4537
$this->cartRepository = $cartRepository;
4638
$this->addProductToCart = $addProductToCart;
47-
$this->lockManager = $lockManager;
4839
}
4940

5041
/**
@@ -58,24 +49,10 @@ public function __construct(
5849
*/
5950
public function execute(Quote $cart, array $cartItems): void
6051
{
61-
/*
62-
$lockName = 'cart_processing_lock_' . $cart->getId();
63-
$needToRefreshCache = false;
64-
while ($this->lockManager->isLocked($lockName)) {
65-
// wait till other process working with the same cart complete
66-
usleep(rand(100, 600));
67-
$needToRefreshCache = true;
68-
}
69-
$this->lockManager->lock($lockName, 1);
70-
if ($needToRefreshCache) {
71-
$this->refreshCartCache($cart);
72-
}
73-
*/
7452
foreach ($cartItems as $cartItemData) {
7553
$this->addProductToCart->execute($cart, $cartItemData);
7654
}
7755
$this->cartRepository->save($cart);
78-
//$this->lockManager->unlock($lockName);
7956
}
8057

8158
/**

0 commit comments

Comments
 (0)