Skip to content

Commit b211748

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

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

app/code/Magento/Customer/Model/Plugin/AllowedCountries.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public function __construct(
4747
*/
4848
public function beforeGetAllowedCountries(
4949
\Magento\Directory\Model\AllowedCountries $subject,
50-
$scopeCode = null,
51-
$scope = ScopeInterface::SCOPE_WEBSITE
50+
$scope = ScopeInterface::SCOPE_WEBSITE,
51+
$scopeCode = null
5252
) {
5353
if ($this->shareConfig->isGlobalScope()) {
5454
//Check if we have shared accounts - than merge all website allowed countries
@@ -58,6 +58,6 @@ public function beforeGetAllowedCountries(
5858
$scope = ScopeInterface::SCOPE_WEBSITES;
5959
}
6060

61-
return [$scopeCode, $scope];
61+
return [$scope, $scopeCode];
6262
}
6363
}

app/code/Magento/Customer/Model/ResourceModel/Address/Attribute/Source/CountryWithWebsites.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function getAllOptions()
7878
if (!$this->shareConfig->isGlobalScope()) {
7979
foreach ($this->storeManager->getWebsites() as $website) {
8080
$countries = $this->allowedCountriesReader
81-
->getAllowedCountries($website->getId(), ScopeInterface::SCOPE_WEBSITE);
81+
->getAllowedCountries(ScopeInterface::SCOPE_WEBSITE, $website->getId());
8282
$allowedCountries = array_merge($allowedCountries, $countries);
8383

8484
foreach ($countries as $countryCode) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,15 @@ private function migrateStoresAllowedCountriesToWebsite(SetupInterface $setup)
195195
foreach ($this->getStoreManager()->getStores() as $store) {
196196
$allowedCountries = $this->mergeAllowedCountries(
197197
$allowedCountries,
198-
$allowedCountriesReader->getAllowedCountries($store->getId(), ScopeInterface::SCOPE_STORE),
198+
$allowedCountriesReader->getAllowedCountries(ScopeInterface::SCOPE_STORE, $store->getId()),
199199
$store->getWebsiteId()
200200
);
201201
}
202202
//Process stores
203203
foreach ($this->getStoreManager()->getWebsites() as $website) {
204204
$allowedCountries = $this->mergeAllowedCountries(
205205
$allowedCountries,
206-
$allowedCountriesReader->getAllowedCountries($website->getId(), ScopeInterface::SCOPE_WEBSITE),
206+
$allowedCountriesReader->getAllowedCountries(ScopeInterface::SCOPE_WEBSITE, $website->getId()),
207207
$website->getId()
208208
);
209209
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ public function __construct(
4949
* @return array
5050
*/
5151
public function getAllowedCountries(
52-
$scopeCode = null,
53-
$scope = ScopeInterface::SCOPE_WEBSITE
52+
$scope = ScopeInterface::SCOPE_WEBSITE,
53+
$scopeCode = null
5454
) {
5555
if (empty($scopeCode)) {
5656
$scopeCode = $this->getDefaultScopeCode($scope);

app/code/Magento/Directory/Model/ResourceModel/Country/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ private function getAllowedCountriesReader()
150150
public function loadByStore($store = null)
151151
{
152152
$allowedCountries = $this->getAllowedCountriesReader()
153-
->getAllowedCountries($store, ScopeInterface::SCOPE_STORE);
153+
->getAllowedCountries(ScopeInterface::SCOPE_STORE, $store);
154154

155155
if (!empty($allowedCountries)) {
156156
$this->addFieldToFilter("country_id", ['in' => $allowedCountries]);

app/code/Magento/Directory/Test/Unit/Model/AllowedCountriesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function testGetAllowedCountries()
6767

6868
$this->assertEquals(
6969
['AM' => 'AM'],
70-
$this->allowedCountriesReader->getAllowedCountries(1, ScopeInterface::SCOPE_WEBSITE, true)
70+
$this->allowedCountriesReader->getAllowedCountries(ScopeInterface::SCOPE_WEBSITE, 1)
7171
);
7272
}
7373
}

0 commit comments

Comments
 (0)