Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-newsletter
Controller
Subscriber
Unsubscribe.php
Go to the documentation of this file.
1
<?php
7
namespace
Magento\Newsletter\Controller\Subscriber
;
8
9
class
Unsubscribe
extends
\Magento\Newsletter\Controller\Subscriber
10
{
15
public
function
execute
()
16
{
17
$id
= (int)$this->
getRequest
()->getParam(
'id'
);
18
$code
= (string)$this->
getRequest
()->getParam(
'code'
);
19
20
if
(
$id
&&
$code
) {
21
try
{
22
$this->_subscriberFactory->create()->load(
$id
)->setCheckCode(
$code
)->unsubscribe();
23
$this->messageManager->addSuccess(
__
(
'You unsubscribed.'
));
24
}
catch
(\
Magento
\Framework\Exception\
LocalizedException
$e) {
25
$this->messageManager->addException($e, $e->getMessage());
26
}
catch
(\Exception $e) {
27
$this->messageManager->addException($e,
__
(
'Something went wrong while unsubscribing you.'
));
28
}
29
}
30
$this->
getResponse
()->setRedirect($this->
_redirect
->getRedirectUrl());
31
}
32
}
Magento\Framework\Exception\LocalizedException
Definition:
LocalizedException.php:17
Magento\Framework\App\Action\Action\_redirect
_redirect($path, $arguments=[])
Definition:
Action.php:167
Magento\Framework\App\Action\AbstractAction\getResponse
getResponse()
Definition:
AbstractAction.php:70
$id
$id
Definition:
fieldset.phtml:14
__
__()
Definition:
__.php:13
Magento\Framework\App\Action\AbstractAction\getRequest
getRequest()
Definition:
AbstractAction.php:60
Magento\Newsletter\Controller\Subscriber
Definition:
Subscriber.php:18
Magento\Newsletter\Controller\Subscriber
Definition:
Confirm.php:7
Magento
Magento\Newsletter\Controller\Subscriber\Unsubscribe\execute
execute()
Definition:
Unsubscribe.php:15
Magento\Newsletter\Controller\Subscriber\Unsubscribe
Definition:
Unsubscribe.php:9
$code
$code
Definition:
info.phtml:12