Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
StockAll.php
Go to the documentation of this file.
1 <?php
7 
10 
12 {
16  public function execute()
17  {
18  try {
19  $this->_objectManager->create(\Magento\ProductAlert\Model\Stock::class)
20  ->deleteCustomer(
21  $this->customerSession->getCustomerId(),
22  $this->_objectManager->get(\Magento\Store\Model\StoreManagerInterface::class)
23  ->getStore()
24  ->getWebsiteId()
25  );
26  $this->messageManager->addSuccess(__('You will no longer receive stock alerts.'));
27  } catch (\Exception $e) {
28  $this->messageManager->addException($e, __('Unable to update the alert subscription.'));
29  }
30 
32  $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
33  return $resultRedirect->setPath('customer/account/');
34  }
35 }
__()
Definition: __.php:13