1

I create a new product and type price= $1.2222. But when I click Save and Continue edit the price = $1.22. I don't want to round the price, i want the price=$1.2222. How can I do that? Thank you!

2

It's because of Mage_Core_Model_Store->roundPrice($price)

/**
 * Round price
 *
 * @param mixed $price
 * @return double
 */
public function roundPrice($price)
{
    return round($price, 2);
}

I've created a module which rewrite core/store and overrides the roundPrice() and has the round($price, 4) inside.

  • Thank you but where can I edit that code? – tuanptit Mar 12 '15 at 10:21
  • 2
    I told you the class name. Search for it. But don't edit the core. At least copy the file in the app/code/local folder keeping the path. – Jeroen Mar 12 '15 at 10:34
0

This is a "feature".
Everything happens because of the input renderer for the price attributes. The Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Price class is used to render the price inputs. At the end of the class there is this method:

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

    if (!is_numeric($value)) {
        return null;
    }

    return number_format($value, 2, null, '');
}

This makes the prices show with only 2 decimals even if in the db there are 4 of them. I guess you have to override this method and replace

return number_format($value, 2, null, '');

with

return number_format($value, 4, null, '');

  • Thank you but where can I edit that code? – tuanptit Mar 12 '15 at 10:21
  • 1
    I told you the class name. Search for it. But don't edit the core. At least copy the file in the app/code/local folder keeping the path. – Marius Mar 12 '15 at 10:23

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.