44 $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
46 $resultRedirect->setPath(
'/');
47 return $resultRedirect;
52 if (!
$product->isVisibleInCatalog()) {
53 throw new NoSuchEntityException();
56 $model = $this->_objectManager->create(\
Magento\ProductAlert\Model\Stock::class)
57 ->setCustomerId($this->customerSession->getCustomerId())
60 $this->_objectManager->get(\
Magento\Store\Model\StoreManagerInterface::class)
68 $this->messageManager->addSuccess(
__(
'You will no longer receive stock alerts for this product.'));
69 }
catch (NoSuchEntityException $noEntityException) {
70 $this->messageManager->addError(
__(
'The product was not found.'));
71 $resultRedirect->setPath(
'customer/account/');
72 return $resultRedirect;
73 }
catch (\Exception $e) {
74 $this->messageManager->addException(
76 __(
"The alert subscription couldn't update at this time. Please try again later.")
79 $resultRedirect->setUrl(
$product->getProductUrl());
80 return $resultRedirect;
__construct(Context $context, CustomerSession $customerSession, ProductRepositoryInterface $productRepository)