34 private $attributeValueProvider;
50 $this->attributeValueProvider = $attributeValueProvider
52 parent::__construct($context);
65 if (!$this->formKeyValidator->validate($this->getRequest())) {
66 return $resultRedirect->setPath(
'*/*/');
69 $id = (int)$this->getRequest()->getParam(
'item');
71 $item = $this->_objectManager->create(Item::class)->load(
$id);
72 if (!
$item->getId()) {
75 $wishlist = $this->wishlistProvider->getWishlist(
$item->getWishlistId());
77 throw new NotFoundException(
__(
'Page not found.'));
82 $productName = $this->attributeValueProvider
83 ->getRawAttributeValue(
$item->getProductId(),
'name');
84 $this->messageManager->addComplexSuccessMessage(
85 'removeWishlistItemSuccessMessage',
87 'product_name' => $productName,
90 }
catch (\
Magento\Framework\Exception\LocalizedException $e) {
91 $this->messageManager->addError(
92 __(
'We can\'t delete the item from Wish List right now because of an error: %1.', $e->getMessage())
94 }
catch (\Exception $e) {
95 $this->messageManager->addError(
__(
'We can\'t delete the item from the Wish List right now.'));
98 $this->_objectManager->get(\
Magento\Wishlist\Helper\Data::class)->calculate();
99 $refererUrl = $this->_redirect->getRefererUrl();
101 $redirectUrl = $refererUrl;
103 $redirectUrl = $this->_redirect->getRedirectUrl($this->_url->getUrl(
'*/*'));
105 $resultRedirect->setUrl($redirectUrl);
106 return $resultRedirect;
__construct(Action\Context $context, WishlistProviderInterface $wishlistProvider, Validator $formKeyValidator, AttributeValueProvider $attributeValueProvider=null)