diff -Nuar a/vendor/magento/module-checkout/Model/Session.php b/vendor/magento/module-checkout/Model/Session.php index 332ce085561..4f5891a8b22 100644 --- a/vendor/magento/module-checkout/Model/Session.php +++ b/vendor/magento/module-checkout/Model/Session.php @@ -6,7 +6,12 @@ namespace Magento\Checkout\Model; use Magento\Customer\Api\Data\CustomerInterface; +use Magento\Framework\Api\SearchCriteriaBuilder; +use Magento\Framework\Api\SortOrderBuilder; use Magento\Framework\App\ObjectManager; +use Magento\Framework\Exception\InputException; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Quote\Api\Data\CartInterface; use Magento\Quote\Model\Quote; use Magento\Quote\Model\QuoteIdMaskFactory; use Psr\Log\LoggerInterface; @@ -267,14 +272,10 @@ class Session extends \Magento\Framework\Session\SessionManager if (!$this->getQuoteId()) { if ($this->_customerSession->isLoggedIn() || $this->_customer) { - $customerId = $this->_customer - ? $this->_customer->getId() - : $this->_customerSession->getCustomerId(); - try { - $quote = $this->quoteRepository->getActiveForCustomer($customerId); + $quoteByCustomer = $this->getQuoteByCustomer(); + if ($quoteByCustomer !== false) { $this->setQuoteId($quote->getId()); - } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { - $this->logger->critical($e); + $quote = $quoteByCustomer; } } else { $quote->setIsCheckoutCart(true); @@ -569,4 +570,22 @@ class Session extends \Magento\Framework\Session\SessionManager { return $this->isQuoteMasked; } + + /** + * @return CartInterface|false + */ + private function getQuoteByCustomer() + { + $customerId = $this->_customer + ? $this->_customer->getId() + : $this->_customerSession->getCustomerId(); + + try { + $quote = $this->quoteRepository->getActiveForCustomer($customerId); + } catch (NoSuchEntityException $e) { + $quote = false; + } + + return $quote; + } }