Guest User

Untitled

a guest
Nov 22nd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. $quote = $this->quoteFactory->create()->load($quoteId);
  2.  
  3. $items = $quote->getAllItems();
  4.  
  5. $items = $quote->getAllItems();
  6.  
  7. foreach ($items as $item) {
  8. $formatedPrice = $item->getPrice();
  9. $quantity = $item['qty'];
  10. $productId = $item->getProductId();
  11.  
  12. $params = array(
  13. 'form_key' => $this->formKey->getFormKey(),
  14. 'product' => $productId, //product Id
  15. 'qty' => $quantity, //quantity of product
  16. 'price' => $formatedPrice //product price
  17. );
  18.  
  19. $_product = $this->_productRepository->getById($productId);
  20.  
  21. if ($_product) {
  22. $this->cart->addProduct($_product, $params);
  23. }
  24. }
  25. try {
  26. $this->cart->save();
  27. $this->messageManager->addSuccess(__('Added to cart successfully.'));
  28. } catch (MagentoFrameworkExceptionLocalizedException $e) {
  29. $this->messageManager->addException($e, __('%1', $e->getMessage()));
  30. }
  31.  
  32. $formatedPrice = $item->getPrice();
Add Comment
Please, Sign In to add comment