I am trying to show currency switcher in custom template file.

I referred some links and found for magento1.

Where they used below code in the template files.

  <?php echo  $this->getLayout()->createBlock('directory/currency')->setTemplate('directory/currency.phtml')->toHtml();?>

Same code i tried in magento2, which is not working.

I have tried this also in my template file.

 <?php echo  $block->getLayout()->createBlock('directory/currency')->setTemplate('directory/currency.phtml')->toHtml();?>

Which is not working.

Can anyone help me is there any other way to achieve this functionality.


  • Good to hear that you have resolved your issue. +1 for anwer acceptance :) – Shoaib Munir Aug 5 '19 at 6:38

Try this code instead:

echo $this->getLayout()

This should work anywhere in any phtml

| improve this answer | |
  • 1
    This worked for me.. Thanks – Manjunath Aug 5 '19 at 6:37
  • 1
    it's working for me – Magento Mar 27 at 17:48

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.