Ads

Tuesday, June 22, 2010

Solution of value has to be numeric error in magento

Error : Value '65,000000' has to be numeric.

Solution :

It just appeared, when your locale number format was not similar to the English one.

Reason:
In app/code/core/Mage/Directory/Model/Currency.php(203) you will find the method 'formatTxt()'.
In there is a fix for a problem with formatted price-values coming in.
In line 211 you'll find the following code:

$price = sprintf("%f", $price);

This sprintf-function does not return the type of its content correctly (has to be double/numeric) if this content (a price-value) is formatted in non-english-style (e.g. '0,0000000 instead of 0.0000000).

In app/code/core/Mage/Directory/Model/Currency.php(212) the method Zend_Currency->toCurrency() is called with the output of the sprintf-function.
So, testing this incoming variable in the Zend-Method to be of numeric type causes the error described above.

Solution:
Replace the sprintf-function with the following code:

$price = (float) $price;

2 comments:

  1. Great blog. All posts have something to learn. Your work is very good and i appreciate you and hoping for some more informative posts.keep writing
    magento development company in bangalore 

    ReplyDelete
  2. Your work is very good and I appreciate you and hopping for some more informative posts Talks Gossip

    ReplyDelete