Skip to content

Commit bb63bca

Browse files
committed
ACP2E-1018: Wrong special price currency
- updating price attributes to apply store currency in Admin instead of default
1 parent bd97c6f commit bb63bca

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

app/code/Magento/Catalog/Ui/DataProvider/Product/Modifier/PriceAttributes.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\Currency;
1111
use Magento\Framework\Exception\NoSuchEntityException;
1212
use Magento\Framework\Locale\CurrencyInterface;
13+
use Magento\Framework\View\Element\UiComponent\ContextInterface;
1314
use Magento\Store\Api\Data\StoreInterface;
1415
use Magento\Store\Model\StoreManagerInterface;
1516
use 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

Comments
 (0)