2

I am working on a custom module that is creating quotes using the Magento quote module.

It is using the \Magento\Quote\Model\QuoteFactory for creating the quotes.

Now I want to checkout the items that are added to the quote and add them to the cart and the checkout page should be displayed to the user with those items that were in the quote.

Here I am creating the quotes as:

$quote = $this->quoteFactory->create()->load($quoteId);

I am adding the products to cart as below,

$quote->setIsActive(1);
if ($quote) {
     try {
     $this->cart->setQuote($quote);
     $this->cart->saveQuote();
     $this->messageManager->addSuccess(__('Added to cart successfully.'));
       } catch (\Magento\Framework\Exception\LocalizedException $e) {
     $this->messageManager->addException($e, __('%1', $e->getMessage()));
        }
     }

However, this gives me an exception as:

No such entity with customerId =

I am not sure why am I getting this. Is there any other way to implement this?

Please, can anyone help?

  • Can anyone please help? I am really stuck here. – manini Nov 23 '17 at 5:10
  • I am facing same kind of issue but not found solution yet :( – Ashish Raj Dec 22 '17 at 11:14
  • do you have got a solution for the issue yet? – Ashish Raj Dec 26 '17 at 10:28
  • @AshishRaj What is exactly your issue? Are you getting the same error as in my case or you want to add the quoted items to cart? – manini Dec 27 '17 at 11:21
  • I have resolved my issue by $quote->save(); – Ashish Raj Dec 28 '17 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.