I've custom block phtml in my old store and I need to be converted to Magento 2.

Magento 1.9.x code:

$_finalPriceInclTax = $this->helper('tax')->getPrice($_product, $_product->getFinalPrice(), true);
$unitPrice = Mage::helper('core')->currency(round($_finalPriceInclTax / $_product->getHedNetWeight(), 2),true,false);

How can I get Final Price included Tax in Magento 2 and how can I use Mage::helper('core')->currency(round) in Magento 2?

I try to display the price like this:

$this->helper('Magento\Framework\Pricing\Helper\Data')->currency($finalprice / $HedNetWeight,true,false);

Thank you


3 Answers 3


In Block :-

protected $priceCurrency;

protected $taxHelper;

public function __construct(\Magento\Catalog\Helper\Data $taxHelper,
    \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
    $this->taxHelper = $taxHelper;
    $this->priceCurrency = $priceCurrency;

public function finalPrice($product) {
    return $this->taxHelper->getTaxPrice($product, $product->getFinalPrice(), true);

public function currency($value, $format = true, $includeContainer = true)
    return $format
    ? $this->priceCurrency->convertAndFormat($value, $includeContainer)
    : $this->priceCurrency->convert($value);

In phtml :-

<?= $block->currency($block->finalPrice(),true,false); ?>
  • 1
    Hi thank you for your answer, but if you read again I need this to be just a simple code in phtml file
    – Robert
    Commented Mar 4, 2019 at 10:38
  • 1
    check my updated answer Commented Mar 4, 2019 at 10:51

Try this one


A couple of extensions allows to change or delete the decimal number for the front store.



  • 1
    Hi thank you, but I don't need a global solution, I need to remove the decimal numbers only in my code
    – Robert
    Commented Mar 4, 2019 at 10:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.