1212use Magento \Framework \Locale \CurrencyInterface ;
1313use Magento \Framework \View \Element \UiComponent \ContextInterface ;
1414use Magento \Store \Api \Data \StoreInterface ;
15+ use Magento \Store \Model \Store ;
1516use Magento \Store \Model \StoreManagerInterface ;
1617use Magento \Ui \DataProvider \Modifier \ModifierInterface ;
1718
@@ -35,6 +36,11 @@ class PriceAttributes implements ModifierInterface
3536 */
3637 private $ localeCurrency ;
3738
39+ /**
40+ * @var ContextInterface
41+ */
42+ private ContextInterface $ context ;
43+
3844 /**
3945 * PriceAttributes constructor.
4046 *
@@ -57,6 +63,8 @@ public function __construct(
5763
5864 /**
5965 * @inheritdoc
66+ * @throws NoSuchEntityException
67+ * @throws \Zend_Currency_Exception
6068 */
6169 public function modifyData (array $ data ): array
6270 {
@@ -67,11 +75,7 @@ public function modifyData(array $data): array
6775 foreach ($ data ['items ' ] as &$ item ) {
6876 foreach ($ this ->priceAttributeList as $ priceAttribute ) {
6977 if (isset ($ 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 ]));
78+ $ item [$ priceAttribute ] = $ this ->getCurrency ()->toCurrency (sprintf ("%f " , $ item [$ priceAttribute ]));
7579 }
7680 }
7781 }
@@ -95,7 +99,9 @@ public function modifyMeta(array $meta): array
9599 */
96100 private function getStore (): StoreInterface
97101 {
98- return $ this ->storeManager ->getStore ();
102+ return $ this ->storeManager ->getStore (
103+ $ this ->context ->getFilterParam ('store_id ' , Store::DEFAULT_STORE_ID )
104+ );
99105 }
100106
101107 /**
0 commit comments