I'm trying to find out if there is any way to remove decimals from layered navigation. We don't have product prices with decimals but Magento show 0-99.99,100-199.99 etc. How this can be achieved?


Your goal could be achieved in the next way:


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    <preference for="Magento\Framework\Pricing\PriceCurrencyInterface"
                type="YourNamespace\YourModule\Model\PriceCurrency" />



namespace YourNamespace\YourModule\Model;

use Magento\Framework\Pricing\PriceCurrencyInterface;

class PriceCurrency extends \Magento\Directory\Model\PriceCurrency implements PriceCurrencyInterface
     * @inheritdoc
    const PRECISION_ZERO = 0;

     * {@inheritdoc}
    public function format(
        $includeContainer = true,
        $precision = self::PRECISION_ZERO,
        $scope = null,
        $currency = null
    ) {
        return $this->getCurrency($scope, $currency)
            ->formatPrecision($amount, $precision, [], $includeContainer);

The rewritten method is used not only for layered navigation. Please test if nothing is broken on frontend before releasing it on live server.

  • Thanks, im trying to look for something which only works for layered navigation. I found this extension github.com/lillik/magento2-price-decimal but its removing decimals from all places. Checking the possibility of customizing it. – Bharath Feb 9 '19 at 13:45

One extension is there with the help of it, you can achieve the rounding.

It will surely help you in some ways.


This module deals with the price rounding management in Magento 2.


you can use round() php function. eg

$price = 129.56
echo round($price);

it will display 130.

  • Where should i use this function, which file and location, please? – Bharath Feb 8 '19 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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