_wishlistData = $wishlistData; $this->_coreRegistry = $registry; parent::__construct($context, $data); } /** * Return wishlist widget options * * @return array */ public function getWishlistOptions() { return ['productType' => $this->escapeHtml($this->getProduct()->getTypeId())]; } /** * Returns product being edited * * @return \Magento\Catalog\Model\Product */ public function getProduct() { return $this->_coreRegistry->registry('product'); } /** * Get update params for http post * * @return bool|string */ public function getUpdateParams() { return $this->_wishlistData->getUpdateParams($this->getWishlistItem()); } /** * Returns wishlist item being configured * * @return \Magento\Catalog\Model\Product|\Magento\Wishlist\Model\Item */ protected function getWishlistItem() { return $this->_coreRegistry->registry('wishlist_item'); } /** * Configure product view blocks * * @return $this */ protected function _prepareLayout() { // Set custom add to cart url $block = $this->getLayout()->getBlock('product.info'); if ($block && $this->getWishlistItem()) { $url = $this->_wishlistData->getAddToCartUrl($this->getWishlistItem()); $block->setCustomAddToCartUrl($url); } return parent::_prepareLayout(); } }