6
6
namespace Magento \Checkout \Model ;
7
7
8
8
use Magento \Customer \Api \Data \CustomerInterface ;
9
- use Magento \Framework \Api \SearchCriteriaBuilder ;
10
- use Magento \Framework \Api \SortOrderBuilder ;
11
9
use Magento \Framework \App \ObjectManager ;
12
- use Magento \Framework \Exception \InputException ;
13
10
use Magento \Framework \Exception \NoSuchEntityException ;
14
11
use Magento \Quote \Api \Data \CartInterface ;
15
12
use Magento \Quote \Model \Quote ;
26
23
*/
27
24
class Session extends \Magento \Framework \Session \SessionManager
28
25
{
29
- /**
30
- * Checkout state begin
31
- */
32
26
const CHECKOUT_STATE_BEGIN = 'begin ' ;
33
27
34
28
/**
@@ -233,7 +227,7 @@ public function setLoadInactive($load = true)
233
227
*
234
228
* @return Quote
235
229
* @throws \Magento\Framework\Exception\LocalizedException
236
- * @throws \Magento\Framework\Exception\ NoSuchEntityException
230
+ * @throws NoSuchEntityException
237
231
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
238
232
* @SuppressWarnings(PHPMD.NPathComplexity)
239
233
*/
@@ -278,16 +272,16 @@ public function getQuote()
278
272
*/
279
273
$ quote = $ this ->quoteRepository ->get ($ this ->getQuoteId ());
280
274
}
281
- } catch (\ Magento \ Framework \ Exception \ NoSuchEntityException $ e ) {
275
+ } catch (NoSuchEntityException $ e ) {
282
276
$ this ->setQuoteId (null );
283
277
}
284
278
}
285
279
286
280
if (!$ this ->getQuoteId ()) {
287
281
if ($ this ->_customerSession ->isLoggedIn () || $ this ->_customer ) {
288
282
$ quoteByCustomer = $ this ->getQuoteByCustomer ();
289
- if ($ quoteByCustomer !== false ) {
290
- $ this ->setQuoteId ($ quote ->getId ());
283
+ if ($ quoteByCustomer !== null ) {
284
+ $ this ->setQuoteId ($ quoteByCustomer ->getId ());
291
285
$ quote = $ quoteByCustomer ;
292
286
}
293
287
} else {
@@ -376,7 +370,7 @@ public function loadCustomerQuote()
376
370
377
371
try {
378
372
$ customerQuote = $ this ->quoteRepository ->getForCustomer ($ this ->_customerSession ->getCustomerId ());
379
- } catch (\ Magento \ Framework \ Exception \ NoSuchEntityException $ e ) {
373
+ } catch (NoSuchEntityException $ e ) {
380
374
$ customerQuote = $ this ->quoteFactory ->create ();
381
375
}
382
376
$ customerQuote ->setStoreId ($ this ->_storeManager ->getStore ()->getId ());
@@ -559,7 +553,7 @@ public function restoreQuote()
559
553
$ this ->replaceQuote ($ quote )->unsLastRealOrderId ();
560
554
$ this ->_eventManager ->dispatch ('restore_quote ' , ['order ' => $ order , 'quote ' => $ quote ]);
561
555
return true ;
562
- } catch (\ Magento \ Framework \ Exception \ NoSuchEntityException $ e ) {
556
+ } catch (NoSuchEntityException $ e ) {
563
557
$ this ->logger ->critical ($ e );
564
558
}
565
559
}
@@ -591,9 +585,9 @@ protected function isQuoteMasked()
591
585
}
592
586
593
587
/**
594
- * @return CartInterface|false
588
+ * Returns quote for customer if there is any
595
589
*/
596
- private function getQuoteByCustomer ()
590
+ private function getQuoteByCustomer (): ? CartInterface
597
591
{
598
592
$ customerId = $ this ->_customer
599
593
? $ this ->_customer ->getId ()
@@ -602,7 +596,7 @@ private function getQuoteByCustomer()
602
596
try {
603
597
$ quote = $ this ->quoteRepository ->getActiveForCustomer ($ customerId );
604
598
} catch (NoSuchEntityException $ e ) {
605
- $ quote = false ;
599
+ $ quote = null ;
606
600
}
607
601
608
602
return $ quote ;
0 commit comments