2

I am upgrading from 2.4.3 to 2.4.5 and see that the code to move currency symbol from left to right of price is not working. How can I update the code to get it to work? Currently I'm using the currency_display_options_forming event hook to add currency options like this (similar to this answer: https://magento.stackexchange.com/a/286889/109359):

public function execute(\Magento\Framework\Event\Observer $observer)
{
    $currencyOptions = $observer->getEvent()->getCurrencyOptions();
    $currencyOptions->setData('position', \Magento\Framework\Currency::RIGHT);
    $currencyOptions->setData('symbol', ',-');

    return $this;
}

The symbol part is working like in 2.4.3, but position is not.

2
  • I ended up using an extension instead: github.com/mageplaza/magento-2-currency-formatter. It is not using the currency_display_options_forming event hook, so I basically avoided the issue.
    – Thomas
    Oct 14, 2022 at 9:40
  • Can you please tell us that your magento 2.4.5 is running fine or not. I want to use Magento 2.4.5 for my site?
    – Rana Zain
    Oct 21, 2022 at 13:00

2 Answers 2

0

Did you cleared cache / static content?

You can try these commands:

rm -rf genenerated/
php bin/magento s:up
php bin/magento setup:static-content:deploy -f
php bin/magento c:f

Also, did you use the 'Magento_Currency' module as a sequence in module.xml?

1
  • Yes, cleared cache/static and also tried adding Magento_Currency in sequence in module.xml, but no change. I can change symbol and I see the change after clearing cache, so it seems to me that the position attribute is simply not working like before.
    – Thomas
    Oct 14, 2022 at 7:01
0

I've stumbled around on this issue today with a Magento 2.4.5 shop. Since no other solutions worked, I started digging through a lot of private methods etc. I found a solution rewriting \Magento\Framework\NumberFormatter to change the pattern given to NumberFormatter.

This way, the currency will be displayed after the numbers.

To make life a bit easier, I've created a module for it,

codepeak/magento2-module-movecurrency

Hope this can help anyone else.

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.