Is there a way to load all items in cart, only using quote entity_id from quote table in magento 2 database?

  • you want the query or the code that retrieves them?
    – Marius
    May 31, 2017 at 7:10
  • @Marius i don't want to load it from raw query, i need to load it from collection
    – simple guy
    May 31, 2017 at 7:12

1 Answer 1


I assume you want to get that in a class.
If not, you should.

Let's say the class name is Vendor\Module\Model\QuoteItems. It should look like this:

namespace  Vendor\Module\Model;

class QuoteItems
    protected $quoteRepository;
    public function __construct(
        \Magento\Quote\Model\QuoteRepository $quoteRepository
        $this->quoteRepository = $quoteRepository;
    public function getQuoteItems($quoteId)
         try {
             $quote = $this->quoteRepository->get($quoteId);
             $items = $quote->getAllItems();
             return $items;
         } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
             return [];

then you can use your class to retrieve the items with the method getQuoteItems.
Or you can use the code inside the method directly, just by injecting an instance of the quote repository in your class.

  • it returns empty array
    – simple guy
    May 31, 2017 at 8:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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