6
6
*/
7
7
namespace Magento \Checkout \Controller \Cart ;
8
8
9
+ use Magento \Checkout \Model \Cart \RequestQuantityProcessor ;
9
10
use Magento \Framework \App \Action \HttpPostActionInterface as HttpPostActionInterface ;
10
11
use Magento \Catalog \Api \ProductRepositoryInterface ;
11
12
use Magento \Checkout \Model \Cart as CustomerCart ;
13
+ use Magento \Framework \App \ObjectManager ;
12
14
use Magento \Framework \App \ResponseInterface ;
13
15
use Magento \Framework \Controller \ResultInterface ;
14
16
use Magento \Framework \Exception \NoSuchEntityException ;
@@ -25,6 +27,11 @@ class Add extends \Magento\Checkout\Controller\Cart implements HttpPostActionInt
25
27
*/
26
28
protected $ productRepository ;
27
29
30
+ /**
31
+ * @var RequestQuantityProcessor
32
+ */
33
+ private $ quantityProcessor ;
34
+
28
35
/**
29
36
* @param \Magento\Framework\App\Action\Context $context
30
37
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
@@ -33,6 +40,7 @@ class Add extends \Magento\Checkout\Controller\Cart implements HttpPostActionInt
33
40
* @param \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator
34
41
* @param CustomerCart $cart
35
42
* @param ProductRepositoryInterface $productRepository
43
+ * @param RequestQuantityProcessor|null $quantityProcessor
36
44
* @codeCoverageIgnore
37
45
*/
38
46
public function __construct (
@@ -42,7 +50,8 @@ public function __construct(
42
50
\Magento \Store \Model \StoreManagerInterface $ storeManager ,
43
51
\Magento \Framework \Data \Form \FormKey \Validator $ formKeyValidator ,
44
52
CustomerCart $ cart ,
45
- ProductRepositoryInterface $ productRepository
53
+ ProductRepositoryInterface $ productRepository ,
54
+ ?RequestQuantityProcessor $ quantityProcessor = null
46
55
) {
47
56
parent ::__construct (
48
57
$ context ,
@@ -53,6 +62,8 @@ public function __construct(
53
62
$ cart
54
63
);
55
64
$ this ->productRepository = $ productRepository ;
65
+ $ this ->quantityProcessor = $ quantityProcessor
66
+ ?? ObjectManager::getInstance ()->get (RequestQuantityProcessor::class);
56
67
}
57
68
58
69
/**
@@ -99,6 +110,7 @@ public function execute()
99
110
\Magento \Framework \Locale \ResolverInterface::class
100
111
)->getLocale ()]
101
112
);
113
+ $ params ['qty ' ] = $ this ->quantityProcessor ->prepareQuantity ($ params ['qty ' ]);
102
114
$ params ['qty ' ] = $ filter ->filter ($ params ['qty ' ]);
103
115
}
104
116
0 commit comments