10
10
use Magento \Framework \Currency ;
11
11
use Magento \Framework \Exception \NoSuchEntityException ;
12
12
use Magento \Framework \Locale \CurrencyInterface ;
13
+ use Magento \Framework \View \Element \UiComponent \ContextInterface ;
13
14
use Magento \Store \Api \Data \StoreInterface ;
14
15
use Magento \Store \Model \StoreManagerInterface ;
15
16
use Magento \Ui \DataProvider \Modifier \ModifierInterface ;
@@ -37,18 +38,21 @@ class PriceAttributes implements ModifierInterface
37
38
/**
38
39
* PriceAttributes constructor.
39
40
*
41
+ * @param ContextInterface $context
40
42
* @param StoreManagerInterface $storeManager
41
43
* @param CurrencyInterface $localeCurrency
42
44
* @param array $priceAttributeList
43
45
*/
44
46
public function __construct (
47
+ ContextInterface $ context ,
45
48
StoreManagerInterface $ storeManager ,
46
49
CurrencyInterface $ localeCurrency ,
47
50
array $ priceAttributeList = []
48
51
) {
49
52
$ this ->storeManager = $ storeManager ;
50
53
$ this ->localeCurrency = $ localeCurrency ;
51
54
$ this ->priceAttributeList = $ priceAttributeList ;
55
+ $ this ->context = $ context ;
52
56
}
53
57
54
58
/**
@@ -63,7 +67,11 @@ public function modifyData(array $data): array
63
67
foreach ($ data ['items ' ] as &$ item ) {
64
68
foreach ($ this ->priceAttributeList as $ priceAttribute ) {
65
69
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 ]));
67
75
}
68
76
}
69
77
}
0 commit comments