How to change currency symbol position in Magento 2 (Left to Right)
Hello, My name is Cuong, I’m a Magento Developer, Welcome back to my Magento 2 tutorial video series. #magento2tutorial #magento2training #magento2
Today, I am going to show everybody the best practice, How to change the currency symbol position in Magento 2.
When you work for a project, you are required to move the currency symbol from left to right or from right to left, you don’t know how to complete this task, you are searching for a solution. Today I show you the best codes to complete your task.
We have the scenario: We will create a new feature that allows the administrator to set the currency symbol position in the Stores → Currency → Currency Symbol Position
So what will we do in this practice?
1. We will create a new module called PHPCuong_CurrencySymbolPosition
2. We will hook to the event named currency_display_options_forming changing currency symbol position set in the configuration
Okie, let’s go.
Let’s complete this practice you need to follow steps by step:
Step 1: Declaring the new module called PHPCuong_CurrencySymbolPosition
– Create the namespace PHPCuong in the path appcode
– Create the module named CurrencySymbolPosition in the path appcodePHPCuong
– Create the file named registration.php in the path appcodePHPCuongCurrencySymbolPosition
– Create the file named module.xml in the path appcodePHPCuongCurrencySymbolPositionetc
End of step #1, I have been completed the codes to create the new module called PHPCuong_CurrencySymbolPosition.
Step 2: Hook to event currency_display_options_forming
– Create the new file named events.xml in the path appcodePHPCuongProductReviewFormetcfrontend
– Create the new file named DisplayOptions.php in the path appcodePHPCuongCurrencySymbolPositionObserver
class DisplayOptions implements
Step 3: Add the new page in the backend allows the administrator to set the value
– Create the new file named acl.xml in the path appcodePHPCuongCurrencySymbolPositionetc
This file helps to define the role resource
– Create the new file named menu.xml in the path appcodePHPCuongCurrencySymbolPositionetcadminhtml
This file helps to define the link named “Currency Symbols Position” under the currency section
– Create the new file named routes.xml in the path appcodePHPCuongCurrencySymbolPositionetcadminhtml
This file helps to define the route path used for the module named PHPCuong_CurrencySymbolPosition in the backend
– Create the new file named Index.php in the path appcodePHPCuongCurrencySymbolPositionControllerAdminhtmlSystemCurrencysymbolposition
This file helps to define the new action named Index in the controller named System_Currencysymbolpostion.
– Create the new file named adminhtml_system_currencysymbolposition_index.xml in the path appcodePHPCuongCurrencySymbolPositionviewadminhtmllayout
– Create the new block named CurrencySymbolPosition.php in the path appcodePHPCuongCurrencySymbolPositionBlockAdminhtmlSystem
– Create the new template named grid.phtml in the path appcodePHPCuongCurrencySymbolPositionviewadminhtmltemplates
– Create the model named CurrencySymbolPosition.php in the path appcodePHPCuongCurrencySymbolPositionModelSystem
This file helps to save the value of currency symbol position in the table named core_config_data
– Create the new file named Save.php in the path appcodePHPCuongCurrencySymbolPositionControllerAdminhtmlSystemCurrencysymbolposition
Step 4: Test and See the results
1. Run the following command lines:
php bin/magento setup:upgrade –keep-generated
php bin/magento setup:di:compile
This process will take much time, please wait for 5 minutes.
This is the codes in the new module, I just created.
I am using the docker on windows 10 pro 64bit for developing Magento 2.
it is better than XAMPP, Vargant.
You can see the tutorial how to use install magento 2 with docker on windows 10 here
php bin/magento cache:flush
2. Go to the Backend.
Stores → Currency → Currency Symbol Position
Change the symbol position for the currencies
You can add more the currency here.
The base currency is USD, so we need to exchange from USD to another.
3. Go to the storefront.
Yeah, It works perfectly.
Thanks for watching the guide. If you have any questions about this practice, please feel free to leave a comment below.
Don’t forget to like, comment, share my videos with your friends and subscribe to my channel for getting other lessons.
Please do not hesitate to contact me, if you need me to join your Magento project. My rate is $25/hour in Magento 1 and $30/hour in Magento 2.
Get the source codes of this practice in the Github