12
12
use Magento \Framework \Locale \CurrencyInterface ;
13
13
use Magento \Framework \View \Element \UiComponent \ContextInterface ;
14
14
use Magento \Store \Api \Data \StoreInterface ;
15
+ use Magento \Store \Model \Store ;
15
16
use Magento \Store \Model \StoreManagerInterface ;
16
17
use Magento \Ui \DataProvider \Modifier \ModifierInterface ;
17
18
@@ -35,6 +36,11 @@ class PriceAttributes implements ModifierInterface
35
36
*/
36
37
private $ localeCurrency ;
37
38
39
+ /**
40
+ * @var ContextInterface
41
+ */
42
+ private ContextInterface $ context ;
43
+
38
44
/**
39
45
* PriceAttributes constructor.
40
46
*
@@ -57,6 +63,8 @@ public function __construct(
57
63
58
64
/**
59
65
* @inheritdoc
66
+ * @throws NoSuchEntityException
67
+ * @throws \Zend_Currency_Exception
60
68
*/
61
69
public function modifyData (array $ data ): array
62
70
{
@@ -67,11 +75,7 @@ public function modifyData(array $data): array
67
75
foreach ($ data ['items ' ] as &$ item ) {
68
76
foreach ($ this ->priceAttributeList as $ priceAttribute ) {
69
77
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 ]));
75
79
}
76
80
}
77
81
}
@@ -95,7 +99,9 @@ public function modifyMeta(array $meta): array
95
99
*/
96
100
private function getStore (): StoreInterface
97
101
{
98
- return $ this ->storeManager ->getStore ();
102
+ return $ this ->storeManager ->getStore (
103
+ $ this ->context ->getFilterParam ('store_id ' , Store::DEFAULT_STORE_ID )
104
+ );
99
105
}
100
106
101
107
/**
0 commit comments