Skip to content

Commit eab0a1e

Browse files
author
Anna Bukatar
committed
ACP2E-2259: Dynamic Blocks based on Customer Segments don't work correctly (Double Banner after Sign Out when using Segment)
1 parent 824661b commit eab0a1e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

app/code/Magento/Customer/Model/Plugin/CustomerNotification.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public function beforeExecute(ActionInterface $subject)
110110

111111
if (!$this->isFrontendRequest()
112112
|| !$this->isPostRequest()
113+
|| $this->isLogoutRequest()
113114
|| !$this->isSessionUpdateRegisteredFor($customerId)) {
114115
return;
115116
}
@@ -146,6 +147,11 @@ private function isPostRequest(): bool
146147
return $this->request instanceof HttpRequestInterface && $this->request->isPost();
147148
}
148149

150+
private function isLogoutRequest(): bool
151+
{
152+
return $this->request->getRequestUri() === '/customer/account/logout/';
153+
}
154+
149155
/**
150156
* Check if the current application area is frontend.
151157
*

app/code/Magento/Customer/Test/Unit/Model/Plugin/CustomerNotificationTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ protected function setUp(): void
8484
$this->customerRepositoryMock = $this->getMockForAbstractClass(CustomerRepositoryInterface::class);
8585
$this->actionMock = $this->getMockForAbstractClass(ActionInterface::class);
8686
$this->requestMock = $this->getMockBuilder(RequestStubInterface::class)
87+
->addMethods(['getRequestUri'])
8788
->getMockForAbstractClass();
8889
$this->requestMock->method('isPost')->willReturn(true);
8990

@@ -153,4 +154,15 @@ public function testBeforeDispatchWithNoCustomerFound()
153154

154155
$this->plugin->beforeExecute($this->actionMock);
155156
}
157+
158+
public function testBeforeExecuteForLogoutRequest()
159+
{
160+
$this->requestMock->method('getRequestUri')->willReturn('/customer/account/logout/');
161+
162+
$this->sessionMock->expects($this->never())->method('regenerateId');
163+
$this->sessionMock->expects($this->never())->method('setCustomerData');
164+
$this->sessionMock->expects($this->never())->method('setCustomerGroupId');
165+
166+
$this->plugin->beforeExecute($this->actionMock);
167+
}
156168
}

0 commit comments

Comments
 (0)