Magento How do I set the product price to 4 decimal places

Magento How do I set the product price to 4 decimal places

September 25, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento How do I set the product price to 4 decimal places

Setting Product Prices to Four Decimal Places in Magento

As an eCommerce developer, I often encounter scenarios where clients require more precision in their product pricing, especially when dealing with taxes like VAT in the UK or Europe. By default, Magento only stores prices up to two decimal places (dp), which can be problematic for calculating tax-inclusive prices accurately.

Challenges in Storing 4-DP Prices

Consider a scenario where you want to set a product price of £15.95 on the frontend but need to store it as £13.5744 in the admin so that when VAT (currently 17.5%) is added, it will display correctly. However, when you enter 13.5744 in the Magento admin, refreshing the page rounds it down to 13.57.

This limitation arises because Magento only stores prices as float data types in the catalog_product_entity_decimal table with a precision of 12 and scale of 4 by default. The scale determines how many digits are stored after the decimal point.

Storing Prices with Four Decimal Places

To store product prices with four decimal places, you need to modify the database schema. Here’s how:

  1. Backup your Magento installation: Before making any changes, ensure you have a complete backup of your files and database.

  2. Alter the database table: Run the following SQL query in your MySQL client or PHPMyAdmin to increase the scale for the catalog_product_entity_decimal table:

ALTER TABLE catalog_product_entity_decimal MODIFY COLUMN value DECIMAL(18,4);

This command changes the value column from a float with 12 precision and 4 scale to a decimal type with 18 precision and 4 scale. The increased precision allows for more digits before the decimal point.

  1. Clear Magento cache: After updating the database, clear your Magento cache to ensure the changes take effect:
php bin/magento cache:clean

Displaying Prices with Two Decimal Places on the Frontend

While storing prices with four decimal places in the admin is now possible, you’ll still want to display them with only two decimal places on the frontend for a cleaner presentation. Magento handles this automatically when using its built-in price rendering methods.

In your product listings and detail pages, use Magento’s price helper functions:

<?= $_product->getPrice() ?>   // For regular prices

or

$priceHtml = $block->getProductPrice($_product);
echo $priceHtml;

These functions will automatically round the displayed price to two decimal places based on your store configuration. The actual stored value (4 dp) is only used for tax calculations and backend display.

Conclusion

Setting product prices with four decimal places in Magento requires a combination of database schema modifications and proper use of its built-in price rendering methods. By following the steps outlined above, you can accurately store prices like £13.5744 in the admin while displaying them as £13.57 on the frontend.

Remember to test these changes thoroughly, especially if your site is live and has existing data. If you need further assistance with Magento development or have questions about other features, feel free to explore our Magento services page.

Happy developing!

Catalog Database Admin Configuration

Our network