How to change Weight Attribute decimals Magento

There is no simple way to change the decimal numbers in the Weight Attribute in Magento.

And is not a specific solution either.

What can we do?

For example, we can force to all numeric attributes to show with 2 decimals.

Open the attributes.phtml located in:

app/design/frontend/YOUR THEME/template/catalog/product/view/

I changed this:

To this:

What it does?

The code above adds a condition is_numeric and uses the round function to round it 😉

After it we just print again the attributes with our new value, in this case $my_data_value

7 Responses to “How to change Weight Attribute decimals Magento”

  1. Bijal January 10, 2014 at 11:13 am #

    Hi Rick,

    The attributes.phtml doesnt exist in the folder you specified. I assume Magento moved it or incorporated it to some other file. Any idea’s where?

    Thanks

  2. Fabien September 29, 2014 at 10:54 am #

    There is an mistake in your code :

    But

    • Rick September 30, 2014 at 10:03 am #

      You’re right, I just updated the post.

      Thank you!

  3. Naim December 19, 2014 at 11:10 pm #

    I tried your modified code but it is not working this is the code I put it

    productAttribute($_product, strip_tags($my_data_value), $_data[‘code’]) ?>

    • Rick December 23, 2014 at 10:30 pm #

      Hi Naim,

      The code was written 4 years ago, are you using a new version of Magento? I’m unaware of possible changed. You should try your luck with the Stackoverflow crew 🙂

  4. Fabien December 24, 2014 at 3:12 pm #

    Hi,
    I use this code on multiples website, this run on Magento 1.8, 1.9, 1.9.1

Leave a Reply

Add <code> Some Code </code> by using this tags.