0

Using Magento 2.2, I need to add the simple and configuration products into the basket by REST API.

On the stack, I saw someone use cart and other use quote.

What the correct solution for add items?

2 Answers 2

2

The cart is mostly used for frontend web application but actually in the background, Magento playing with a quote(means managing quote) when customer adding the products to the cart.

Magento quote handling Simple products as a single item while for the configurable product there are two items adding into the cart first is configurable or parent product and second is its simple or child product.

In the rest API, we need to create quote first and then add products in that quote via custom code.

Still, you have doubts please let me know.

4
  • Thank, Nits. Could you add new items (configuration product) by quote? Jun 13, 2018 at 8:53
  • Nits. And could you show me sample code with 'configuration product' adding to quote? Jun 13, 2018 at 9:02
  • You don't need to add custom code for the configurable product, you need to pass attribute value in the post request. The code would be same for both configurable and simple product. You can check this via adding logs in the cart controller while adding the product to the cart from the frontend and then you will get a clear idea about this. Please accept above answer as correct, if it's helpfull to you.
    – Nits
    Jun 13, 2018 at 9:06
  • Nits, where is ''cart controller' ? Jun 13, 2018 at 9:19
2

Nits, where is cart controller?

Below is answer for this question

You can find the cart controller in below path:

vendor\magento\module-checkout\Controller\Cart\Index.php

vendor\magento\module-checkout\Controller\Cart\Add.php
0

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.