Skip to content

Commit 847f217

Browse files
committed
ACP2E-182: Error while validating Store VAT Number
1 parent ae614cc commit 847f217

File tree

4 files changed

+62
-40
lines changed

4 files changed

+62
-40
lines changed

app/code/Magento/Config/Helper/Country.php

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Config\ViewModel;
9+
10+
use Magento\Framework\App\Config\ScopeConfigInterface;
11+
use Magento\Framework\View\Element\Block\ArgumentInterface;
12+
use Magento\Store\Model\ScopeInterface;
13+
14+
class CountryFilter implements ArgumentInterface
15+
{
16+
/**
17+
* Config path to UE country list
18+
*/
19+
private const XML_PATH_EU_COUNTRIES_LIST = 'general/country/eu_countries';
20+
21+
/**
22+
* @var ScopeConfigInterface
23+
*/
24+
private $scopeConfig;
25+
26+
/**
27+
* @param ScopeConfigInterface $scopeConfig
28+
*/
29+
public function __construct(
30+
ScopeConfigInterface $scopeConfig
31+
) {
32+
$this->scopeConfig = $scopeConfig;
33+
}
34+
35+
/**
36+
* Fetch EU countries list
37+
*
38+
* @param Int|null $storeId
39+
* @return false|string[]
40+
*/
41+
public function getEuCountryList($storeId = null)
42+
{
43+
$euCountries = explode(
44+
',',
45+
$this->scopeConfig->getValue(
46+
self::XML_PATH_EU_COUNTRIES_LIST,
47+
ScopeInterface::SCOPE_STORE,
48+
$storeId
49+
)
50+
);
51+
52+
return $euCountries;
53+
}
54+
}

app/code/Magento/Config/view/adminhtml/layout/adminhtml_system_config_edit.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
99
<body>
1010
<referenceContainer name="js">
11-
<block class="Magento\Backend\Block\Template" name="js.system_config_js" template="Magento_Config::system/config/js.phtml"/>
11+
<block class="Magento\Backend\Block\Template" name="js.system_config_js" template="Magento_Config::system/config/js.phtml">
12+
<arguments>
13+
<argument name="countryFilter" xsi:type="object">Magento\Config\ViewModel\CountryFilter</argument>
14+
</arguments>
15+
</block>
1216
<block class="Magento\Backend\Block\Template" name="js.system_shipping_applicable_country" template="Magento_Backend::system/shipping/applicable_country.phtml"/>
1317
</referenceContainer>
1418
<referenceContainer name="page.main.actions">

app/code/Magento/Config/view/adminhtml/templates/system/config/js.phtml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
/**
88
* @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer
9+
* @var \Magento\Config\ViewModel\CountryFilter $countryFilter
910
*/
1011
?>
1112

@@ -86,7 +87,8 @@ originModel.prototype = {
8687
script;
8788

8889
$scriptString .= 'this.regionsUrl = "' . $block->escapeJs($block->getUrl('directory/json/countryRegion')) . '";';
89-
$euCountries = $this->helper(\Magento\Config\Helper\Country::class)->getEuCountryList();
90+
$countryFilter = $block->getData('countryFilter');
91+
$euCountries = $countryFilter->getEuCountryList();
9092
$scriptString .= 'this.euCountryList = ' . json_encode($euCountries);
9193

9294
$scriptString .= <<<script

0 commit comments

Comments
 (0)