Currency Converter – Accurate and Fast Currency Conversion Tool

currency

How Convert USD to INR ( base currency) in magento?.
I tried to below code , but not working.

$amt=1000;
Mage::helper('directory')->currencyConvert($amt, 'USD', 'INR'); 

But its work on Mage::helper('directory')->currencyConvert($amt, 'INR', 'USD');

Best Answer

You cannot convert one price currency price to base currency.

because magento did not calculate base currency rate from other current rate.

Magento define a price in BASE currency which will convert using rate for other currency

Magento is calculate other price from base Currency

Please got see Mage_Directory_Model_Currency class on function

 public function convert($price, $toCurrency=null)
    {
        if (is_null($toCurrency)) {
            return $price;
        }
        elseif ($rate = $this->getRate($toCurrency)) {
            return $price*$rate;
        }

        throw new Exception(Mage::helper('directory')->__('Undefined rate from "%s-%s".', $this->getCode(), $toCurrency->getCode()));
    }

Here show that you can not get base currency from other currency

That means that you code format is

Mage::helper('directory')->currencyConvert($amt, 'baseCurrecy', 'your currency');

revise it not possible using this function

Mage::helper('directory')->currencyConvert($amt, 'your currency', 'baseCurrecy');