wishlistProvider = $wishlistProvider; $this->registry = $registry; $this->customerSession = $customerSession; parent::__construct($context); } /** * Shared wishlist view page * * @return \Magento\Framework\Controller\ResultInterface */ public function execute() { $wishlist = $this->wishlistProvider->getWishlist(); $customerId = $this->customerSession->getCustomerId(); if ($wishlist && $wishlist->getCustomerId() && $wishlist->getCustomerId() == $customerId) { /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); $resultRedirect->setUrl( $this->_objectManager->get(\Magento\Wishlist\Helper\Data::class)->getListUrl($wishlist->getId()) ); return $resultRedirect; } $this->registry->register('shared_wishlist', $wishlist); /** @var \Magento\Framework\View\Result\Page $resultPage */ $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE); return $resultPage; } }