Reading list Switch to dark mode

    Programmatically change/set the current currency of store in Magento 2.

    Updated 7 August 2018

    In this Article I am going to explain, how to change the current currency of the store.
    Need : If you are developing Api’s or creating the custom module, the situation may come, when you need to change the current currency of store.
    To get the right behaviour for the target.

    Here we go :

    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    $storeManager = $objectManager->get(\Magento\Store\Model\StoreManagerInterface::class);
    $currency = "USD";
    if ($currency) {
       $storeManager->getStore()->setCurrentCurrencyCode($currency);
    }

    $currency is a currency code in which you want to set the current currency to your store.

    Searching for an experienced
    Magento 2 Company ?
    Find out More
    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    6 comments

  • Satish V
    • Prabhat Rawat (Moderator)
  • Patrick van Bergen
    • Prabhat Rawat (Moderator)
  • Rajesh Gohil
    • Prabhat Rawat (Moderator)
  • Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home