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?


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.


We can do this using Constructor injection.

 * @var \Magento\Framework\Locale\CurrencyInterface
protected $_localeCurrency

public function __construct(
    \Magento\Framework\Locale\CurrencyInterface $localeCurrency
    $this->_localecurrency = $localeCurrency;

Now you can use below code in your function to get currency symbol.


To get the symbol:

$_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$_Symbol = $_objectManager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($_code);
echo $_Symbol->getCurrencySymbol();
  • Your code doesn't work. $_code is not defined. – J Plana Jan 25 '17 at 20:52

Instead of using object manager try with currency interface

public function __construct(
        \Magento\Framework\Locale\CurrencyInterface $localeCurrency
    $this->localecurrency = $localeCurrency;

For full code please refer here http://webhintsexplorer.com/magento-2-get-currency-symbol-by-code/


It also works like this:

$objectManager =  \Magento\Framework\App\ObjectManager::getInstance();

$storeManager =$objectManager>get('\Magento\Store\Model\StoreManagerInterface');
$currency = $objectManager->get('\Magento\Directory\Model\Currency');

$store = $storeManager->getStore();


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.