Question

I'm trying to get quote on checkout and this exception is thrown in

vendor\magento\module-checkout\Model\Session.php:241

exception.log

Message: Infinite loop detected, review the trace for the looping path 
{"exception":"[object] (Exception(code: 0): Report ID: webapi-
6e4533bg2n381; Message: Infinite loop detected, review the trace for the 
looping path at /public_html/vendor/magento/framework/Webapi
/ErrorProcessor.php:208, LogicException(code: 0): Infinite loop detected,
review the trace for the looping path at /public_html/vendor/magento
/module-checkout/Model/Session.php:241)"} []

The problem is in overridden \Magento\Tax\Model\Config getShippingTaxClass() where I use

$cart = $objectManager->get('\Magento\Checkout\Model\Cart'); 
$quote = $cart->getQuote();
$itemsCollection = $quote->getItemsCollection();

and this triggers the exception. There is no loop around it.

What would be to correct way of getting cart items in 2.3.4?

Était-ce utile?

La solution

Getting items directly from session was causing this error so I only got quote id from session and then used CartRepositoryInterface to retrieve items.

$session = $objectManager->get('\Magento\Checkout\Model\Session');
$quote_repository = $objectManager->get('\Magento\Quote\Api\CartRepositoryInterface');
$qid = $session->getQuoteId();
$quote = $quote_repository->get($qid);      
// retrieve quote items
$items = $quote->getAllItems();
Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange
scroll top