Skip to content

Commit bbbca23

Browse files
committed
MC-32873: Product stock alert - unsubscribe for the product not working (logged out user)
1 parent 1116437 commit bbbca23

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

app/code/Magento/ProductAlert/Controller/Add.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
use Magento\Customer\Model\Session as CustomerSession;
1111
use Magento\Framework\App\RequestInterface;
1212

13+
/**
14+
* Abstract controller for notifying.
15+
*/
1316
abstract class Add extends Action
1417
{
1518
/**
@@ -39,8 +42,8 @@ public function dispatch(RequestInterface $request)
3942
{
4043
if (!$this->customerSession->authenticate()) {
4144
$this->_actionFlag->set('', 'no-dispatch', true);
42-
if (!$this->customerSession->getBeforeUrl()) {
43-
$this->customerSession->setBeforeUrl($this->_redirect->getRefererUrl());
45+
if (!$this->customerSession->getBeforeAuthUrl()) {
46+
$this->customerSession->setBeforeAuthUrl($this->_redirect->getRefererUrl());
4447
}
4548
}
4649
return parent::dispatch($request);

app/code/Magento/ProductAlert/Controller/Unsubscribe/Email.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@
88

99
namespace Magento\ProductAlert\Controller\Unsubscribe;
1010

11+
use Magento\Customer\Model\Session as CustomerSession;
1112
use Magento\Framework\App\Action\Context;
1213
use Magento\Framework\App\Action\HttpGetActionInterface;
13-
use Magento\Framework\App\Action\Action;
1414
use Magento\Framework\View\Result\Page;
1515
use Magento\Framework\View\Result\PageFactory;
16+
use Magento\ProductAlert\Controller\Unsubscribe as UnsubscribeController;
1617

1718
/**
1819
* Unsubscribing from 'Back in stock Alert'.
1920
*
2021
* Is used to transform a Get request that triggered in the email into the Post request endpoint
2122
*/
22-
class Email extends Action implements HttpGetActionInterface
23+
class Email extends UnsubscribeController implements HttpGetActionInterface
2324
{
2425
/**
2526
* @var PageFactory
@@ -29,13 +30,15 @@ class Email extends Action implements HttpGetActionInterface
2930
/**
3031
* @param Context $context
3132
* @param PageFactory $resultPageFactory
33+
* @param CustomerSession $customerSession
3234
*/
3335
public function __construct(
3436
Context $context,
35-
PageFactory $resultPageFactory
37+
PageFactory $resultPageFactory,
38+
CustomerSession $customerSession
3639
) {
3740
$this->resultPageFactory = $resultPageFactory;
38-
parent::__construct($context);
41+
parent::__construct($context, $customerSession);
3942
}
4043

4144
/**

app/code/Magento/ProductAlert/view/frontend/layout/productalert_unsubscribe_email.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
99
<body>
1010
<referenceContainer name="content">
11-
<block class="Magento\Framework\View\Element\Template" name="unsubscription_form" template="Magento_ProductAlert::email/email.phtml" />
11+
<block class="Magento\Framework\View\Element\Template" name="unsubscription_form" cacheable="false" template="Magento_ProductAlert::email/email.phtml" />
1212
</referenceContainer>
1313
</body>
1414
</page>

0 commit comments

Comments
 (0)