Magento: How to get Currency Rates?

You can see the currency Rates from Magento Admin
System -> Manage Currency Rates

You can change base currency and allowed currencies from
System -> Configuration -> GENERAL -> Currency Setup -> Currency Options

Now, here I will show you how you can get currency rates values for any given currency code.

Here, I will be fetching currency rates for base currency. You can keep any currency code instead of basecurrency.


/**
 * Get the base currency
 */
$baseCurrencyCode = Mage::app()->getBaseCurrencyCode();		

/**
 * Get all allowed currencies
 * returns array of allowed currency codes
 */
$allowedCurrencies = Mage::getModel('directory/currency')
							->getConfigAllowCurrencies();	

/** 
 * Get the currency rates
 * returns array with key as currency code and value as currency rate
 */
$currencyRates = Mage::getModel('directory/currency')
						->getCurrencyRates($baseCurrencyCode, array_values($allowedCurrencies));

Similarly, you can get currency rates for any currency code. But remember that the currency should be set as allowed currency in
System -> Configuration -> GENERAL -> Currency Setup -> Currency Options -> Allowed Currencies


$allowedCurrencies = Mage::getModel('directory/currency')
							->getConfigAllowCurrencies();	

/**
 * Get currency rates for Nepalese Currency
 */
$currencyRates = Mage::getModel('directory/currency')
						->getCurrencyRates('NPR', array_values($allowedCurrencies));

Hope this helps. Thanks.