10
10
use Magento \Framework \GraphQl \Exception \GraphQlInputException ;
11
11
use Magento \Quote \Api \CartRepositoryInterface ;
12
12
use Magento \Quote \Model \Quote ;
13
- use Magento \Framework \Lock \LockManagerInterface ;
14
13
15
14
/**
16
15
* Adding products to cart using GraphQL
@@ -27,24 +26,16 @@ class AddProductsToCart
27
26
*/
28
27
private $ addProductToCart ;
29
28
30
- /**
31
- * @var LockManagerInterface
32
- */
33
- private $ lockManager ;
34
-
35
29
/**
36
30
* @param CartRepositoryInterface $cartRepository
37
31
* @param AddSimpleProductToCart $addProductToCart
38
- * @param LockManagerInterface $lockManager
39
32
*/
40
33
public function __construct (
41
34
CartRepositoryInterface $ cartRepository ,
42
- AddSimpleProductToCart $ addProductToCart ,
43
- LockManagerInterface $ lockManager
35
+ AddSimpleProductToCart $ addProductToCart
44
36
) {
45
37
$ this ->cartRepository = $ cartRepository ;
46
38
$ this ->addProductToCart = $ addProductToCart ;
47
- $ this ->lockManager = $ lockManager ;
48
39
}
49
40
50
41
/**
@@ -58,24 +49,10 @@ public function __construct(
58
49
*/
59
50
public function execute (Quote $ cart , array $ cartItems ): void
60
51
{
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
- */
74
52
foreach ($ cartItems as $ cartItemData ) {
75
53
$ this ->addProductToCart ->execute ($ cart , $ cartItemData );
76
54
}
77
55
$ this ->cartRepository ->save ($ cart );
78
- //$this->lockManager->unlock($lockName);
79
56
}
80
57
81
58
/**
0 commit comments