Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Render.php
Go to the documentation of this file.
1 <?php
8 
14 
23 class Render extends Template
24 {
28  protected $registry;
29 
37  public function __construct(
38  Template\Context $context,
40  array $data = []
41  ) {
42  $this->registry = $registry;
43  parent::__construct($context, $data);
44  }
45 
51  protected function _toHtml()
52  {
54  $priceRender = $this->getLayout()->getBlock($this->getPriceRender());
55  if ($priceRender instanceof PricingRender) {
56  $product = $this->getProduct();
57  if ($product instanceof SaleableInterface) {
58  $arguments = $this->getData();
59  $arguments['render_block'] = $this;
60  return $priceRender->render($this->getPriceTypeCode(), $product, $arguments);
61  }
62  }
63  return parent::_toHtml();
64  }
65 
71  protected function getProduct()
72  {
73  $parentBlock = $this->getParentBlock();
74 
75  $product = $parentBlock && $parentBlock->getProductItem()
76  ? $parentBlock->getProductItem()
77  : $this->registry->registry('product');
78  return $product;
79  }
80 }
__construct(Template\Context $context, Registry $registry, array $data=[])
Definition: Render.php:37
getData($key='', $index=null)
Definition: DataObject.php:119
$parentBlock
Definition: details.phtml:11
$arguments