

$finalPriceModel = $block->getPriceType('final_price') ** \Magento\Framework\Pricing\Price\PriceInterface $finalPriceModel */ ** ex: \Magento\Catalog\Pricing\Price\FinalPrice */ $priceModel = $block->getPriceType('regular_price') ** \Magento\Framework\Pricing\Price\PriceInterface $priceModel */ ** ex: \Magento\Catalog\Pricing\Price\RegularPrice */ $currentProductId = $block->getRequest()->getParam('id') Now, the final step is to create a custom template for the final price and do changes as per your requirement.įile: app/code/Aureatelabs/PriceTemplate/view/frontend/templates/product/price/final_price_related_product.phtml $price = $priceRender->render($priceType, $product, $arguments)
APPCODE PRICING CODE
Step 5: Override related product list blockĪs we want to change the price template for only related product only, now we need to override \Magento\Catalog\Block\Product\ProductList\Related, so first create a preference in di.xml file.įile: app/code/Aureatelabs/PriceTemplate/etc/frontend/di.xmlĬopy Code Copied Use a different Browser getLayout()->getBlock('') Here we’ve layout block which was defined previously in catalog_product_view.xml file of our module. $priceRender = $rendererPool->createPriceRender($priceCode, $saleableItem, $useArguments) Throw new \RuntimeException('Wrong Price Rendering layout configuration. $rendererPool = $this->priceLayout->getBlock('') ** \Magento\Framework\Pricing\Render\RendererPool $rendererPool */ Hence create the same class and extend Magento\Framework\Pricing\Renderįile: app/code/Aureatelabs/PriceTemplate/Pricing/Render.phpĬopy Code Copied Use a different Browser _data, $arguments) Magento\Catalog\Pricing\Render\FinalPriceBoxĪureatelabs_PriceTemplate::product/price/final_price_related_product.phtmlĪs mentioned in step 2, Block type of is Aureatelabs\PriceTemplate\Pricing\Render Magento_Catalog::product/price/amount/default.phtml Magento_Catalog::product/price/default.phtml Then include the needed registration.php and module.xml files.įile: app/code/Aureatelabs/PriceTemplate/registration.phpĬopy Code Copied Use a different Browser For that, you need to override module-catalog/view/base/templates/product/price/final_price.phtml Step 1: Create a sample moduleĬreate a new module named PriceTemplate under app/code/Aureatelabs/.
APPCODE PRICING HOW TO
Hence being one of the top Magento web development companies, we wrote a custom module that will show you how to use custom price templates for related product lists. final_price.phtml, tier_price.phtml, default.phtml). For example, Special Price is represented by the final price type in the code and uses a separate template for each price(e.g. final price, minimum price, maximum price, regular price) and is separate from the actual price in the code. Magento represents these prices as price types (e.g.
