@@ -181,6 +181,21 @@ private function mergeAllowedCountries(array $countries, array $newCountries, $i
181
181
return $ countries ;
182
182
}
183
183
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
+
184
199
/**
185
200
* Migrate and merge allowed countries
186
201
*
@@ -189,21 +204,21 @@ private function mergeAllowedCountries(array $countries, array $newCountries, $i
189
204
*/
190
205
private function migrateStoresAllowedCountriesToWebsite (SetupInterface $ setup )
191
206
{
192
- $ allowedCountriesReader = $ this -> getAllowedCountriesReader ();
207
+
193
208
$ allowedCountries = [];
194
209
//Process Websites
195
210
foreach ($ this ->getStoreManager ()->getStores () as $ store ) {
196
211
$ allowedCountries = $ this ->mergeAllowedCountries (
197
212
$ allowedCountries ,
198
- $ allowedCountriesReader ->getAllowedCountries (ScopeInterface::SCOPE_STORE , $ store ->getId ()),
213
+ $ this ->getAllowedCountries (ScopeInterface::SCOPE_STORE , $ store ->getId ()),
199
214
$ store ->getWebsiteId ()
200
215
);
201
216
}
202
217
//Process stores
203
218
foreach ($ this ->getStoreManager ()->getWebsites () as $ website ) {
204
219
$ allowedCountries = $ this ->mergeAllowedCountries (
205
220
$ allowedCountries ,
206
- $ allowedCountriesReader ->getAllowedCountries (ScopeInterface::SCOPE_WEBSITE , $ website ->getId ()),
221
+ $ this ->getAllowedCountries (ScopeInterface::SCOPE_WEBSITE , $ website ->getId ()),
207
222
$ website ->getId ()
208
223
);
209
224
}
0 commit comments