1

I am trying to get the details of a product whose quote has been inactive. I am getting the following error when i use the this code.

$cartItem = $this->quoteItem->load($itemId);
return $cartItem->getProduct();

Uncaught Error: Call to a member function getStoreId() on null in /var/www/vhosts/avesh/vendor/magento/module-quote/Model/Quote/Item/AbstractItem.php:146

1 Answer 1

1

That's happening because your item has no quote, because it is inactive. If you want to work with item, you must load corresponding quote and set it to that item manually or, you can load a quote and get all items from it using $quote->getAllItems() method. Then you can filter that items and get desired one with all data (product, quote etc).

1
  • Thank you for the solution. However i also solved it using itemcollection with a filter for item_id, then fetched the product from it.
    – Avesh Naik
    Commented Jan 29, 2020 at 6:50

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.