Wednesday, September 7, 2011

Magento Convert price from One Currency to Another Currency

Here is a quick code to convert price amount from one currency to another currency. From the code below, you can convert any currency you desire. You just need the ‘From Currency Code’ and ‘To Currency Code’. Make sure you have imported exchange rate in your admin backend.
$fromCurrency = 'USD'; // currency code to convert from - usually your base currency
$toCurrency = 'EUR'; // currency to convert to
$price = Mage::helper('directory')->
    currencyConvert($_product->getFinalPrice(), $fromCurrency, $toCurrency);
// if you want it rounded:
$final_price = Mage::app()->getStore()->roundPrice($price);

No comments:

Post a Comment