Magento 2 – Get Currency Symbol from Currency Code

currencymagento2PHP

I have below code

$currencyManager        = $_objectManager->create('Magento\Directory\Model\CurrencyFactory')->create()->getResource(); 
echo $currencySymbol    = $currencyManager->getCurrencyCodeFromToCurrency('USD');

It gives fatal error

Fatal error: Call to undefined method Magento\Directory\Model\ResourceModel\Currency::getCurrencyCodeFromToCurrency()

Can anybody guide me to get Currency Symbol from Currency Code?

Best Answer

It should be:

$currency = $_objectManager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($currencyCode);
$currencySymbol = $currency->getCurrencySymbol();

It would be beter to use CurrencyRepository but it's not yet implemented in Magento 2.

Related Topic