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 :) Aug 5, 2019 at 6:38

1 Answer 1


Try this code instead:

echo $this->getLayout()

This should work anywhere in any phtml

  • 1
    This worked for me.. Thanks
    – Manjunath
    Aug 5, 2019 at 6:37
  • 1
    it's working for me Mar 27, 2020 at 17:48

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.