ScopeConfigInterface::SCOPE_TYPE_DEFAULT, 'value' => null, ]; $request = $this->_getRequest(); if ($request->getParam(ScopeInterface::SCOPE_WEBSITE)) { $scope = [ 'type' => ScopeInterface::SCOPE_WEBSITE, 'value' => $request->getParam(ScopeInterface::SCOPE_WEBSITE), ]; } elseif ($request->getParam(ScopeInterface::SCOPE_STORE)) { $scope = [ 'type' => ScopeInterface::SCOPE_STORE, 'value' => $request->getParam(ScopeInterface::SCOPE_STORE), ]; } elseif ($request->getParam(self::STORE_ID)) { $scope = [ 'type' => ScopeInterface::SCOPE_STORE, 'value' => $request->getParam(self::STORE_ID), ]; } return $scope; } /** * Retrieve regions data * * @return array */ public function getRegionData() { $scope = $this->getCurrentScope(); $allowedCountries = $this->scopeConfig->getValue( AllowedCountries::ALLOWED_COUNTRIES_PATH, $scope['type'], $scope['value'] ); $countryIds = explode(',', $allowedCountries); $collection = $this->_regCollectionFactory->create(); $collection->addCountryFilter($countryIds)->load(); $regions = [ 'config' => [ 'show_all_regions' => $this->isShowNonRequiredState(), 'regions_required' => $this->getCountriesWithStatesRequired(), ], ]; foreach ($collection as $region) { /** @var $region Region */ if (!$region->getRegionId()) { continue; } $regions[$region->getCountryId()][$region->getCode()] = [ 'code' => $region->getCode(), 'name' => (string)__($region->getName()), ]; } return $regions; } }