priceLayout = $priceLayout; parent::__construct($context, $data); } /** * Prepare layout * * @return $this */ protected function _prepareLayout() { $this->priceLayout->addHandle($this->getPriceRenderHandle()); $this->priceLayout->loadLayout(); return parent::_prepareLayout(); } /** * Render price * * @param string $priceCode * @param SaleableInterface $saleableItem * @param array $arguments * @return string * @throws \InvalidArgumentException * @throws \RuntimeException */ public function render($priceCode, SaleableInterface $saleableItem, array $arguments = []) { $useArguments = array_replace($this->_data, $arguments); /** @var \Magento\Framework\Pricing\Render\RendererPool $rendererPool */ $rendererPool = $this->priceLayout->getBlock('render.product.prices'); if (!$rendererPool) { throw new \RuntimeException('Wrong Price Rendering layout configuration. Factory block is missed'); } // obtain concrete Price Render $priceRender = $rendererPool->createPriceRender($priceCode, $saleableItem, $useArguments); return $priceRender->toHtml(); } /** * Render price amount * * @param AmountInterface $amount * @param PriceInterface $price * @param SaleableInterface $saleableItem * @param array $arguments * @return string * @throws \RuntimeException */ public function renderAmount( AmountInterface $amount, PriceInterface $price, SaleableInterface $saleableItem = null, array $arguments = [] ) { $useArguments = array_replace($this->_data, $arguments); /** @var \Magento\Framework\Pricing\Render\RendererPool $rendererPool */ $rendererPool = $this->priceLayout->getBlock('render.product.prices'); if (!$rendererPool) { throw new \RuntimeException('Wrong Price Rendering layout configuration. Factory block is missed'); } // obtain concrete Amount Render $amountRender = $rendererPool->createAmountRender($amount, $saleableItem, $price, $useArguments); return $amountRender->toHtml(); } }