I want currency Symbol using currency code in magento 2. so any one help me?

I have tried below code but I got error Class Magento\Directory\Model\CurrencyFact‌​ory does not exist

$_objectManager = \Magento\Framework\App\ObjectManager::getInstance(); 
$currencyManager = $_objectManager->create('Magento\Directory\Model\CurrencyFac‌​tory')->create()->ge‌​tResource(); 
echo $currencySymbol = $currencyManager->getCurrencyCodeFromToCurrency($_code);
  • I want currency Symbol using currency code in magento 2. so any one help me? Dec 7, 2016 at 7:49
  • 1
    @Marius This boy only wants currency code that's why voted this for reopen, may be some one can easily answer this question Dec 7, 2016 at 7:51
  • @MurtuzaZabuawala if you say you can answer this I will reopen it, but this looks like a poorly asked question to me.
    – Marius
    Dec 7, 2016 at 7:52
  • 2
    @SusantaKumarDas here is your answer magento.stackexchange.com/questions/130102/… Dec 7, 2016 at 7:55
  • <?php $_objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $currencyManager = $_objectManager->create('Magento\Directory\Model\CurrencyFactory')->create()->getResource(); echo $currencySymbol = $currencyManager->getCurrencyCodeFromToCurrency($_code); ?> I am use this code but not working. Dec 7, 2016 at 8:01

6 Answers 6

class Customclass{
    protected $storeManager;
    protected $currencySymbol;
    protected $localeCurrency;
    public function __construct(
        \Magento\Store\Model\StoreManagerInterface $storeManager,
        \Magento\Directory\Model\Currency $currencySymbol,
        \Magento\Framework\Locale\CurrencyInterface $localeCurrency
    ) {
        $this->_storeManager = $storeManager;
        $this->currencySymbol = $currencySymbol;
        $this->localecurrency = $localeCurrency;

    public function getStoreCurrency(){
        $currencycode = $this->_storeManager->getStore()->getCurrentCurrencyCode();
        return $this->localecurrency->getCurrency($currencycode)->getSymbol();
  • Are this serious? All of that just to get a "$"/"R$"/"€"/etc symbol? Oct 9, 2020 at 14:07
  • Maybe a PR with a helper to do that could be good, let's try.. Oct 9, 2020 at 14:08

There is no method available of

you can use like this to get currency symbol.

 $om = \Magento\Framework\App\ObjectManager::getInstance();
 $currencyManager = $om->get('Magento\Directory\Model\Currency'); 
 echo $currencyManager->getCurrencySymbol();

or you set currency symbol using below code.

$priceHelper = $om->get('Magento\Framework\Pricing\Helper\Data');
echo $priceHelper->currency($price, true, false);

To get the symbol:

$_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$_Symbol = $_objectManager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($_code);
echo $_Symbol->getCurrencySymbol();

To get Currency symbol use the following code into your phtml or your block.

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$currencysymbol = $objectManager->get('Magento\Directory\Model\Currency')->getCurrencySymbol();

or replace get with create sometime I have faced this issue according to the location of code like block, controller, Model or phtml.

$currencysymbol = $objectManager->create('Magento\Directory\Model\Currency')->getCurrencySymbol();

this is the code

$_objectManager = \Magento\Framework\App\ObjectManager::getInstance(); 
echo $_objectManager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($_code)->getCurrencySymbol();

To get the Currency Symbol :

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

$priceHelper = $objectManager->create('Magento\Framework\Pricing\Helper\Data');

$price =  1000; //Your Price

$formattedPrice = $priceHelper->currency($price, true, false);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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