I have created multi currency website in Magento 1.9. On product page I'm trying to get current currency symbol using below code :
$symbol = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();
This code is working for all currency except AED
. For AED
currency above code return NULL
.
Why this is happening?
How to resolve it?
Best Answer
It seems like Magento does not have Symbols for some of the currencies. You need to add symbols for these currencies manually.
To add currency symbol, Go to
System > Manage Currencies > Symbol
PS: There are some more currencies which does not have default symbols available in Magento. e.g. SEK, SDG, GQE
EDIT
I have debug default Magento Currency display functionality and I found below. When Magento displays product price, It calls function
Mage_Directory_Model_Currency::formatTxt($price, $options = array())
This function then returns below
Here
toCurrency
function is called from lib/Zend/Currency.phpZend_Currency::toCurrency($value = null, array $options = array())
For
AED
currency it sends one parameter in$options['display']
with value3
If youvar_dump($options)
in this function you will get all data like below.In the same function there is below code.
This code defines what symbol, string to append for price. For
AED
it usesUSE_SHORTNAME
, and thus it adds currency short name and not symbol.That is the reason you see Currency symbol (which is actually currency short name) in price and not in your code
As you can see in
var_dump
data the symbol value for AED isnull