1010use Magento \Framework \Currency ;
1111use Magento \Framework \Exception \NoSuchEntityException ;
1212use Magento \Framework \Locale \CurrencyInterface ;
13+ use Magento \Framework \View \Element \UiComponent \ContextInterface ;
1314use Magento \Store \Api \Data \StoreInterface ;
1415use Magento \Store \Model \StoreManagerInterface ;
1516use Magento \Ui \DataProvider \Modifier \ModifierInterface ;
@@ -37,18 +38,21 @@ class PriceAttributes implements ModifierInterface
3738 /**
3839 * PriceAttributes constructor.
3940 *
41+ * @param ContextInterface $context
4042 * @param StoreManagerInterface $storeManager
4143 * @param CurrencyInterface $localeCurrency
4244 * @param array $priceAttributeList
4345 */
4446 public function __construct (
47+ ContextInterface $ context ,
4548 StoreManagerInterface $ storeManager ,
4649 CurrencyInterface $ localeCurrency ,
4750 array $ priceAttributeList = []
4851 ) {
4952 $ this ->storeManager = $ storeManager ;
5053 $ this ->localeCurrency = $ localeCurrency ;
5154 $ this ->priceAttributeList = $ priceAttributeList ;
55+ $ this ->context = $ context ;
5256 }
5357
5458 /**
@@ -63,7 +67,11 @@ public function modifyData(array $data): array
6367 foreach ($ data ['items ' ] as &$ item ) {
6468 foreach ($ this ->priceAttributeList as $ priceAttribute ) {
6569 if (isset ($ item [$ priceAttribute ])) {
66- $ item [$ priceAttribute ] = $ this ->getCurrency ()->toCurrency (sprintf ("%f " , $ item [$ priceAttribute ]));
70+ $ store = $ this ->storeManager ->getStore (
71+ $ this ->context ->getFilterParam ('store_id ' , \Magento \Store \Model \Store::DEFAULT_STORE_ID )
72+ );
73+ $ currency = $ this ->localeCurrency ->getCurrency ($ store ->getBaseCurrencyCode ());
74+ $ item [$ priceAttribute ] = $ currency ->toCurrency (sprintf ("%f " , $ item [$ priceAttribute ]));
6775 }
6876 }
6977 }
0 commit comments