Question

I need to change Magento's default decimal format. I mean, when I save '1' to a decimal field, it becomes '10000.0000' with this '.0000' in the end.

I need to change it to another format, which uses ',' instead of '.' to separate decimal (and currency) numbers.

This is the Brazilian standard and it's not being used even after changing the store language. This change should be reflected mainly in the admin side.

Thanks a lot!

PS: this is exactly the same question posted here by myself: https://stackoverflow.com/questions/19041708/change-magento-decimal-field-format

Was it helpful?

Solution

I've applied the following change to the file magento\js\prototype\validation.js (line 426):

|| (!isNaN(parseNumber(v)) && /^\s*-?\d*(\,\d*)?\s*$/.test(v));

and also, changed the file lib/Varien/Data/Form/Element/Abstract.php by adding the first if statement:

public function getEscapedValue($index=null)
{
    $value = $this->getValue($index);

    if(is_numeric($value)){
        $value= number_format($value, 3, ",", ".");
    }
    ...

this changes have solved the problem so far. Do you see any side-effect?

Comments are welcome! Thanks!

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top