Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Configure.php
Go to the documentation of this file.
1 <?php
14 
20 {
26  protected $_wishlistData = null;
27 
33  protected $_coreRegistry = null;
34 
41  public function __construct(
42  \Magento\Framework\View\Element\Template\Context $context,
43  \Magento\Wishlist\Helper\Data $wishlistData,
44  \Magento\Framework\Registry $registry,
45  array $data = []
46  ) {
47  $this->_wishlistData = $wishlistData;
48  $this->_coreRegistry = $registry;
49  parent::__construct($context, $data);
50  }
51 
57  public function getWishlistOptions()
58  {
59  return ['productType' => $this->escapeHtml($this->getProduct()->getTypeId())];
60  }
61 
67  public function getProduct()
68  {
69  return $this->_coreRegistry->registry('product');
70  }
71 
77  public function getUpdateParams()
78  {
79  return $this->_wishlistData->getUpdateParams($this->getWishlistItem());
80  }
81 
87  protected function getWishlistItem()
88  {
89  return $this->_coreRegistry->registry('wishlist_item');
90  }
91 
97  protected function _prepareLayout()
98  {
99  // Set custom add to cart url
100  $block = $this->getLayout()->getBlock('product.info');
101  if ($block && $this->getWishlistItem()) {
102  $url = $this->_wishlistData->getAddToCartUrl($this->getWishlistItem());
103  $block->setCustomAddToCartUrl($url);
104  }
105 
106  return parent::_prepareLayout();
107  }
108 }
$block
Definition: block.php:8
__construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Wishlist\Helper\Data $wishlistData, \Magento\Framework\Registry $registry, array $data=[])
Definition: Configure.php:41