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(
108
108
*/
109
109
public function setGuest ($ checkQuote = false )
110
110
{
111
- $ this ->persistentSession ->getSession ()->removePersistentCookie ();
112
- $ this ->persistentSession ->setSession (null );
113
-
114
111
/** @var $quote Quote */
115
112
$ quote = $ this ->checkoutSession ->getQuote ();
116
113
if ($ quote && $ quote ->getId ()) {
@@ -134,6 +131,9 @@ public function setGuest($checkQuote = false)
134
131
$ quote ->collectTotals ();
135
132
$ this ->quoteRepository ->save ($ quote );
136
133
}
134
+
135
+ $ this ->persistentSession ->getSession ()->removePersistentCookie ();
136
+ $ this ->persistentSession ->setSession (null );
137
137
}
138
138
139
139
/**
Original file line number Diff line number Diff line change @@ -96,6 +96,8 @@ public function execute(\Magento\Framework\Event\Observer $observer)
96
96
}
97
97
98
98
if (!$ cart || $ cart ->getItemsCount () == 0 ) {
99
+ $ this ->customerSession ->setCustomerId (null )
100
+ ->setCustomerGroupId (null );
99
101
$ this ->quoteManager ->setGuest ();
100
102
}
101
103
}
Original file line number Diff line number Diff line change @@ -137,6 +137,13 @@ public function testExecuteWithEmptyCart()
137
137
->with ($ customerId )
138
138
->willReturn ($ quoteMock );
139
139
$ 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 );
140
147
$ this ->quoteManagerMock ->expects ($ this ->once ())->method ('setGuest ' );
141
148
142
149
$ this ->model ->execute ($ this ->observerMock );
@@ -160,6 +167,13 @@ public function testExecuteWithNonexistentCart()
160
167
->method ('getActiveForCustomer ' )
161
168
->with ($ customerId )
162
169
->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 );
163
177
$ this ->quoteManagerMock ->expects ($ this ->once ())->method ('setGuest ' );
164
178
165
179
$ this ->model ->execute ($ this ->observerMock );
You can’t perform that action at this time.
0 commit comments