wishlistProvider = $wishlistProvider; $this->_coreRegistry = $coreRegistry; $this->resultPageFactory = $resultPageFactory; parent::__construct($context); } /** * Action to reconfigure wishlist item * * @return \Magento\Framework\Controller\ResultInterface * @throws NotFoundException */ public function execute() { $id = (int)$this->getRequest()->getParam('id'); /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); try { /* @var $item \Magento\Wishlist\Model\Item */ $item = $this->_objectManager->create(\Magento\Wishlist\Model\Item::class); $item->loadWithOptions($id); if (!$item->getId()) { throw new \Magento\Framework\Exception\LocalizedException( __("The Wish List item can't load at this time. Please try again later.") ); } $wishlist = $this->wishlistProvider->getWishlist($item->getWishlistId()); if (!$wishlist) { throw new NotFoundException(__('Page not found.')); } $this->_coreRegistry->register('wishlist_item', $item); $params = new \Magento\Framework\DataObject(); $params->setCategoryId(false); $params->setConfigureMode(true); $buyRequest = $item->getBuyRequest(); if (!$buyRequest->getQty() && $item->getQty()) { $buyRequest->setQty($item->getQty()); } if ($buyRequest->getQty() && !$item->getQty()) { $item->setQty($buyRequest->getQty()); $this->_objectManager->get(\Magento\Wishlist\Helper\Data::class)->calculate(); } $params->setBuyRequest($buyRequest); /** @var \Magento\Framework\View\Result\Page $resultPage */ $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE); $this->_objectManager->get( \Magento\Catalog\Helper\Product\View::class )->prepareAndRender( $resultPage, $item->getProductId(), $this, $params ); return $resultPage; } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->messageManager->addError($e->getMessage()); $resultRedirect->setPath('*'); return $resultRedirect; } catch (\Exception $e) { $this->messageManager->addError(__('We can\'t configure the product right now.')); $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); $resultRedirect->setPath('*'); return $resultRedirect; } } }