Skip to content

Commit c79ff5d

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

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Framework\Locale\CurrencyInterface;
1313
use Magento\Framework\View\Element\UiComponent\ContextInterface;
1414
use Magento\Store\Api\Data\StoreInterface;
15+
use Magento\Store\Model\Store;
1516
use Magento\Store\Model\StoreManagerInterface;
1617
use 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

Comments
 (0)