Skip to content

Commit 551a15c

Browse files
author
Sergii Kovalenko
committed
MAGETWO-56936: [Backport][Github] Allowed countries for customer address in admin using storeview configuration #2946
1 parent b211748 commit 551a15c

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

app/code/Magento/Customer/Setup/UpgradeData.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,21 @@ private function mergeAllowedCountries(array $countries, array $newCountries, $i
181181
return $countries;
182182
}
183183

184+
/**
185+
* Retrieve unqiue allowed countries by scope
186+
*
187+
* @param string $scope
188+
* @param int $scopeCode
189+
* @return array
190+
*/
191+
private function getAllowedCountries($scope, $scopeCode)
192+
{
193+
$allowedCountriesReader = $this->getAllowedCountriesReader();
194+
return $allowedCountriesReader->getUniqueCountries(
195+
$allowedCountriesReader->getCountriesFromConfig($scope, $scopeCode)
196+
);
197+
}
198+
184199
/**
185200
* Migrate and merge allowed countries
186201
*
@@ -189,21 +204,21 @@ private function mergeAllowedCountries(array $countries, array $newCountries, $i
189204
*/
190205
private function migrateStoresAllowedCountriesToWebsite(SetupInterface $setup)
191206
{
192-
$allowedCountriesReader = $this->getAllowedCountriesReader();
207+
193208
$allowedCountries = [];
194209
//Process Websites
195210
foreach ($this->getStoreManager()->getStores() as $store) {
196211
$allowedCountries = $this->mergeAllowedCountries(
197212
$allowedCountries,
198-
$allowedCountriesReader->getAllowedCountries(ScopeInterface::SCOPE_STORE, $store->getId()),
213+
$this->getAllowedCountries(ScopeInterface::SCOPE_STORE, $store->getId()),
199214
$store->getWebsiteId()
200215
);
201216
}
202217
//Process stores
203218
foreach ($this->getStoreManager()->getWebsites() as $website) {
204219
$allowedCountries = $this->mergeAllowedCountries(
205220
$allowedCountries,
206-
$allowedCountriesReader->getAllowedCountries(ScopeInterface::SCOPE_WEBSITE, $website->getId()),
221+
$this->getAllowedCountries(ScopeInterface::SCOPE_WEBSITE, $website->getId()),
207222
$website->getId()
208223
);
209224
}

app/code/Magento/Directory/Model/AllowedCountries.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private function getDefaultScopeCode($scope)
105105
* @param array $allowedCountries
106106
* @return array
107107
*/
108-
private function getUniqueCountries(array $allowedCountries)
108+
public function getUniqueCountries(array $allowedCountries)
109109
{
110110
return array_combine($allowedCountries, $allowedCountries);
111111
}
@@ -117,7 +117,7 @@ private function getUniqueCountries(array $allowedCountries)
117117
* @param int $scopeCode
118118
* @return array
119119
*/
120-
private function getCountriesFromConfig($scope, $scopeCode)
120+
public function getCountriesFromConfig($scope, $scopeCode)
121121
{
122122
return explode(
123123
',',

0 commit comments

Comments
 (0)