1

I am bit confused magento price data formating is done, I am working on custome module whete I need to display order amount in grid, I done it, its working fine but I am getting 4 places of decimal points for example 14.0000, I need it display like 14.00 only,

my grid add column function that print order amount is as below.

$this->addColumn('order_amount', array(
          'header'    => Mage::helper('manoreport')->__('Order Amount'),
          'width'     => '100px',
          'type'=>'price',
          'index'     => 'subtotal_invoiced',
        ));

but it still looks like this only

enter image description here

Any Suggestions.? Thanks in Advance:)

5

You need to specify a currency.

$this->addColumn('order_amount', array(
      'header'    => Mage::helper('manoreport')->__('Order Amount'),
      'width'     => '100px',
      'type'      => 'price',
      'index'     => 'subtotal_invoiced',
      'currency_code' => 'CURRENCY CODE HERE' 
    ));

If the currency may be different from order to order (most probably is) you can make the column be of type currency instead of price.

$this->addColumn('order_amount', array(
      'header'    => Mage::helper('manoreport')->__('Order Amount'),
      'width'     => '100px',
      'type'      => 'currency',
      'index'     => 'subtotal_invoiced',
      'currency'  => 'order_currency_code'//this will take the currency from the order - this represents the column that holds the currency code
    ));
  • When i tried to use 'order_currency_code', Magento complained "Currency 'order_currency_code' does not exist". Instead i had to create a renderer extending the Currency renderer, get the currency code from the order passed into the renderer function and set that on the column object, then return the parent::renderer – Robert Stanley Jul 15 '15 at 13:45
  • How to achieve this in magento 2 custom grid? – Purushotam Sharma Aug 30 '17 at 5:24

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.