Skip to content

Commit 96b969d

Browse files
david-fuehrhostep
authored andcommitted
make implementation more clear
remove empty catch block
1 parent 8920923 commit 96b969d

File tree

2 files changed

+26
-63
lines changed

2 files changed

+26
-63
lines changed

app/code/Magento/Checkout/Model/Session.php

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
namespace Magento\Checkout\Model;
77

88
use Magento\Customer\Api\Data\CustomerInterface;
9+
use Magento\Framework\Api\SearchCriteriaBuilder;
10+
use Magento\Framework\Api\SortOrderBuilder;
911
use Magento\Framework\App\ObjectManager;
12+
use Magento\Framework\Exception\InputException;
13+
use Magento\Framework\Exception\NoSuchEntityException;
14+
use Magento\Quote\Api\Data\CartInterface;
1015
use Magento\Quote\Model\Quote;
1116
use Magento\Quote\Model\QuoteIdMaskFactory;
1217
use Psr\Log\LoggerInterface;
@@ -280,13 +285,10 @@ public function getQuote()
280285

281286
if (!$this->getQuoteId()) {
282287
if ($this->_customerSession->isLoggedIn() || $this->_customer) {
283-
$customerId = $this->_customer
284-
? $this->_customer->getId()
285-
: $this->_customerSession->getCustomerId();
286-
287-
$quote = $this->quoteRepository->getForCustomer($customerId);
288-
if ($quote->getIsActive()) {
288+
$quoteByCustomer = $this->getQuoteByCustomer();
289+
if ($quoteByCustomer !== false) {
289290
$this->setQuoteId($quote->getId());
291+
$quote = $quoteByCustomer;
290292
}
291293
} else {
292294
$quote->setIsCheckoutCart(true);
@@ -587,4 +589,22 @@ protected function isQuoteMasked()
587589
{
588590
return $this->isQuoteMasked;
589591
}
592+
593+
/**
594+
* @return CartInterface|false
595+
*/
596+
private function getQuoteByCustomer()
597+
{
598+
$customerId = $this->_customer
599+
? $this->_customer->getId()
600+
: $this->_customerSession->getCustomerId();
601+
602+
try {
603+
$quote = $this->quoteRepository->getActiveForCustomer($customerId);
604+
} catch (NoSuchEntityException $e) {
605+
$quote = false;
606+
}
607+
608+
return $quote;
609+
}
590610
}

app/code/Magento/Checkout/Test/Unit/Model/var/allure-results/e72b83d2-ff74-4a91-8151-0820931a7442-testsuite.xml

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)