Skip to content

Commit e165a70

Browse files
committed
AC-13019: Currency configuration issue fixed
1 parent bca0482 commit e165a70

File tree

3 files changed

+63
-2
lines changed

3 files changed

+63
-2
lines changed

app/code/Magento/Backend/Block/Dashboard/Orders/Grid.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* Adminhtml dashboard recent orders grid
1515
*
1616
* @api
17-
* @author Magento Core Team <core@magentocommerce.com>
1817
* @SuppressWarnings(PHPMD.DepthOfInheritance)
1918
* @since 100.0.2
2019
*/
@@ -152,7 +151,7 @@ protected function _prepareColumns()
152151
'header' => __('Total'),
153152
'sortable' => false,
154153
'type' => 'currency',
155-
'currency_code' => $baseCurrencyCode,
154+
'currency_code' => $this->escapeHtml($baseCurrencyCode),
156155
'index' => 'revenue'
157156
]
158157
);
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Config\Plugin\Model\Config\Backend;
10+
11+
use Magento\Config\Model\Config\Backend\Locale;
12+
use Magento\Config\Model\Config\Source\Locale\Currency\All;
13+
use Magento\Framework\Exception\LocalizedException;
14+
15+
class LocalePlugin
16+
{
17+
/**
18+
* @var All
19+
*/
20+
private $currencyList;
21+
22+
/**
23+
* @param All $currencyList
24+
*/
25+
public function __construct(
26+
All $currencyList
27+
) {
28+
$this->currencyList = $currencyList;
29+
}
30+
31+
/**
32+
* Check whether currency code value is acceptable or not
33+
*
34+
* @param Locale $subject
35+
* @return void
36+
*/
37+
public function beforeSave(Locale $subject): void
38+
{
39+
if ($subject->isValueChanged()) {
40+
$values = $subject->getValue();
41+
if (count(array_diff($values, $this->getOptions()))) {
42+
throw new LocalizedException(__('There was an error save new configuration value.'));
43+
}
44+
}
45+
}
46+
47+
/**
48+
* Get available options for weight unit
49+
*
50+
* @return array
51+
*/
52+
private function getOptions()
53+
{
54+
$options = $this->currencyList->toOptionArray();
55+
56+
return array_column($options, 'value');
57+
}
58+
}

app/code/Magento/Config/etc/adminhtml/di.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@
99
<preference for="Magento\Config\Model\Config\Backend\File\RequestData\RequestDataInterface" type="Magento\Config\Model\Config\Backend\File\RequestData" />
1010
<type name="Magento\Config\Model\Config\Structure\Element\Iterator\Tab" shared="false" />
1111
<type name="Magento\Config\Model\Config\Structure\Element\Iterator\Section" shared="false" />
12+
<type name="Magento\Config\Model\Config\Backend\Locale">
13+
<plugin name="installed_currency_configuration_validation"
14+
type="Magento\Config\Plugin\Model\Config\Backend\LocalePlugin" sortOrder="10" />
15+
</type>
1216
</config>

0 commit comments

Comments
 (0)