Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $quote = $this->quoteFactory->create()->load($quoteId);
- $items = $quote->getAllItems();
- $items = $quote->getAllItems();
- foreach ($items as $item) {
- $formatedPrice = $item->getPrice();
- $quantity = $item['qty'];
- $productId = $item->getProductId();
- $params = array(
- 'form_key' => $this->formKey->getFormKey(),
- 'product' => $productId, //product Id
- 'qty' => $quantity, //quantity of product
- 'price' => $formatedPrice //product price
- );
- $_product = $this->_productRepository->getById($productId);
- if ($_product) {
- $this->cart->addProduct($_product, $params);
- }
- }
- try {
- $this->cart->save();
- $this->messageManager->addSuccess(__('Added to cart successfully.'));
- } catch (MagentoFrameworkExceptionLocalizedException $e) {
- $this->messageManager->addException($e, __('%1', $e->getMessage()));
- }
- $formatedPrice = $item->getPrice();
Add Comment
Please, Sign In to add comment