66 */
77namespace Magento \Checkout \Controller \Cart ;
88
9+ use Magento \Checkout \Model \Cart \RequestQuantityProcessor ;
910use Magento \Framework \App \Action \HttpPostActionInterface as HttpPostActionInterface ;
1011use Magento \Catalog \Api \ProductRepositoryInterface ;
1112use Magento \Checkout \Model \Cart as CustomerCart ;
13+ use Magento \Framework \App \ObjectManager ;
1214use Magento \Framework \App \ResponseInterface ;
1315use Magento \Framework \Controller \ResultInterface ;
1416use Magento \Framework \Exception \NoSuchEntityException ;
@@ -25,6 +27,11 @@ class Add extends \Magento\Checkout\Controller\Cart implements HttpPostActionInt
2527 */
2628 protected $ productRepository ;
2729
30+ /**
31+ * @var RequestQuantityProcessor
32+ */
33+ private $ quantityProcessor ;
34+
2835 /**
2936 * @param \Magento\Framework\App\Action\Context $context
3037 * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
@@ -33,6 +40,7 @@ class Add extends \Magento\Checkout\Controller\Cart implements HttpPostActionInt
3340 * @param \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator
3441 * @param CustomerCart $cart
3542 * @param ProductRepositoryInterface $productRepository
43+ * @param RequestQuantityProcessor|null $quantityProcessor
3644 * @codeCoverageIgnore
3745 */
3846 public function __construct (
@@ -42,7 +50,8 @@ public function __construct(
4250 \Magento \Store \Model \StoreManagerInterface $ storeManager ,
4351 \Magento \Framework \Data \Form \FormKey \Validator $ formKeyValidator ,
4452 CustomerCart $ cart ,
45- ProductRepositoryInterface $ productRepository
53+ ProductRepositoryInterface $ productRepository ,
54+ ?RequestQuantityProcessor $ quantityProcessor = null
4655 ) {
4756 parent ::__construct (
4857 $ context ,
@@ -53,6 +62,8 @@ public function __construct(
5362 $ cart
5463 );
5564 $ this ->productRepository = $ productRepository ;
65+ $ this ->quantityProcessor = $ quantityProcessor
66+ ?? ObjectManager::getInstance ()->get (RequestQuantityProcessor::class);
5667 }
5768
5869 /**
@@ -99,6 +110,7 @@ public function execute()
99110 \Magento \Framework \Locale \ResolverInterface::class
100111 )->getLocale ()]
101112 );
113+ $ params ['qty ' ] = $ this ->quantityProcessor ->prepareQuantity ($ params ['qty ' ]);
102114 $ params ['qty ' ] = $ filter ->filter ($ params ['qty ' ]);
103115 }
104116
0 commit comments