-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
During website implementations I often had to access currency information like the currency symbol of a price (e.g. for custom API resources, or when rendering a price on a graphical banner).
For that purpose the currency information for a given AbstractPrice instance should be made accessable for the current locale.
Currently this information is hidden 4 levels away:
Pricing\Price\AbstractPricehas a privateMagento\Directory\Model\PriceCurrencyPriceCurrencygives access toMagento\Directory\Model\Currencyvia the publicgetCurrency()Currencyhas a privateMagento\Framework\Locale\CurrencyLocale\Currencyuses aCurrencyFactoryto instantiate aMagento\Framework\Currencywhich is exposed viagetCurrency()but requires a currency code as an argument.Magento\Framework\Currencyfinally extendsZend_Currencyand thus implementsgetSymbol()
Is there already a good way to access that information, for example in a price template?
If not, I think the cleanest way to access the data would be via getter methods on the AbstractPrice instances.
Ideally a method getCurrencySymbol would be added to the Magento\Framework\Pricing\Price\PriceInterface and implemented in AbstractPrice.
Would that be something you generally agree with?