45 $this->_countryCollectionFactory = $countryCollectionFactory;
46 $this->_regionCollectionFactory = $regionCollectionFactory;
55 $this->loadCountries();
57 if (isset($this->iso2Countries[$countryCode])) {
58 $countryId = $this->iso2Countries[$countryCode];
59 }
elseif (isset($this->iso3Countries[$countryCode])) {
60 $countryId = $this->iso3Countries[$countryCode];
71 protected function loadCountries()
73 if ($this->iso2Countries !==
null && $this->iso3Countries !==
null) {
77 $this->iso2Countries = [];
78 $this->iso3Countries = [];
81 $collection = $this->_countryCollectionFactory->create();
83 $this->iso2Countries[
$row[
'iso2_code']] =
$row[
'country_id'];
84 $this->iso3Countries[
$row[
'iso3_code']] =
$row[
'country_id'];
96 $this->loadCountries();
97 return isset($this->iso2Countries[$countryCode]) || isset($this->iso3Countries[$countryCode]);
107 $this->loadRegions();
108 return isset($this->regions[$countryId][$regionCode]);
116 protected function loadRegions()
118 if ($this->regions !==
null) {
125 $collection = $this->_regionCollectionFactory->create();
127 $this->regions[
$row[
'country_id']][
$row[
'code']] = (int)
$row[
'region_id'];
140 $this->loadRegions();
141 return $this->regions[$countryId][$regionCode];
elseif(isset( $params[ 'redirect_parent']))
__construct(\Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollectionFactory, \Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionCollectionFactory)
$_countryCollectionFactory
getCountryId($countryCode)
getRegionId($countryId, $regionCode)
$_regionCollectionFactory
hasCountryId($countryCode)
hasRegionId($countryId, $regionCode)