File tree Expand file tree Collapse file tree 3 files changed +19
-3
lines changed
app/code/Magento/Persistent Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -108,9 +108,6 @@ public function __construct(
108108 */
109109 public function setGuest ($ checkQuote = false )
110110 {
111- $ this ->persistentSession ->getSession ()->removePersistentCookie ();
112- $ this ->persistentSession ->setSession (null );
113-
114111 /** @var $quote Quote */
115112 $ quote = $ this ->checkoutSession ->getQuote ();
116113 if ($ quote && $ quote ->getId ()) {
@@ -134,6 +131,9 @@ public function setGuest($checkQuote = false)
134131 $ quote ->collectTotals ();
135132 $ this ->quoteRepository ->save ($ quote );
136133 }
134+
135+ $ this ->persistentSession ->getSession ()->removePersistentCookie ();
136+ $ this ->persistentSession ->setSession (null );
137137 }
138138
139139 /**
Original file line number Diff line number Diff line change @@ -96,6 +96,8 @@ public function execute(\Magento\Framework\Event\Observer $observer)
9696 }
9797
9898 if (!$ cart || $ cart ->getItemsCount () == 0 ) {
99+ $ this ->customerSession ->setCustomerId (null )
100+ ->setCustomerGroupId (null );
99101 $ this ->quoteManager ->setGuest ();
100102 }
101103 }
Original file line number Diff line number Diff line change @@ -137,6 +137,13 @@ public function testExecuteWithEmptyCart()
137137 ->with ($ customerId )
138138 ->willReturn ($ quoteMock );
139139 $ quoteMock ->expects ($ this ->once ())->method ('getItemsCount ' )->willReturn ($ emptyCount );
140+ $ this ->customerSessionMock ->expects ($ this ->once ())
141+ ->method ('setCustomerId ' )
142+ ->with (null )
143+ ->willReturnSelf ();
144+ $ this ->customerSessionMock ->expects ($ this ->once ())
145+ ->method ('setCustomerGroupId ' )
146+ ->with (null );
140147 $ this ->quoteManagerMock ->expects ($ this ->once ())->method ('setGuest ' );
141148
142149 $ this ->model ->execute ($ this ->observerMock );
@@ -160,6 +167,13 @@ public function testExecuteWithNonexistentCart()
160167 ->method ('getActiveForCustomer ' )
161168 ->with ($ customerId )
162169 ->willThrowException ($ exception );
170+ $ this ->customerSessionMock ->expects ($ this ->once ())
171+ ->method ('setCustomerId ' )
172+ ->with (null )
173+ ->willReturnSelf ();
174+ $ this ->customerSessionMock ->expects ($ this ->once ())
175+ ->method ('setCustomerGroupId ' )
176+ ->with (null );
163177 $ this ->quoteManagerMock ->expects ($ this ->once ())->method ('setGuest ' );
164178
165179 $ this ->model ->execute ($ this ->observerMock );
You can’t perform that action at this time.
0 commit comments