45 private $allowedCountriesReader;
58 \Psr\Log\LoggerInterface
$logger,
60 \
Magento\Framework\Event\ManagerInterface $eventManager,
61 \
Magento\Framework\Locale\ResolverInterface $localeResolver,
65 $this->_localeResolver = $localeResolver;
79 $this->_countryTable = $this->
getTable(
'directory_country');
80 $this->_regionNameTable = $this->
getTable(
'directory_country_region_name');
93 parent::_initSelect();
94 $locale = $this->_localeResolver->getLocale();
98 [
'rname' => $this->_regionNameTable],
99 'main_table.region_id = rname.region_id AND rname.locale = :region_locale',
112 private function getAllowedCountriesReader()
114 if (!$this->allowedCountriesReader) {
118 return $this->allowedCountriesReader;
131 $allowedCountries = $this->getAllowedCountriesReader()
132 ->getAllowedCountries(ScopeInterface::SCOPE_STORE,
$store);
134 if (!empty($allowedCountries)) {
135 $this->
addFieldToFilter(
'main_table.country_id', [
'in' => $allowedCountries]);
149 if (!empty($countryId)) {
150 if (is_array($countryId)) {
168 [
'country' => $this->_countryTable],
169 'main_table.country_id = country.country_id' 171 'country.iso3_code = ?',
186 if (!empty($regionCode)) {
187 if (is_array($regionCode)) {
204 if (!empty($regionName)) {
205 if (is_array($regionName)) {
222 if (!empty($region)) {
223 $condition = is_array($region) ? [
'in' => $region] : $region;
225 [
'main_table.code',
'main_table.default_name'],
226 [$condition, $condition]
241 'value' =>
'region_id',
242 'title' =>
'default_name',
243 'country_id' =>
'country_id',
246 foreach ($this as
$item) {
248 foreach ($propertyMap as
$code => $field) {
258 [
'title' =>
'',
'value' =>
'',
'label' =>
__(
'Please select a region, state or province.')]
addBindParam($name, $value)
addCountryFilter($countryId)
__construct(\Magento\Framework\Data\Collection\EntityFactory $entityFactory, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\Locale\ResolverInterface $localeResolver, \Magento\Framework\DB\Adapter\AdapterInterface $connection=null, \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource=null)
addAllowedCountriesFilter($store=null)
addFieldToFilter($attribute, $condition=null)
addRegionNameFilter($regionName)
addOrder($field, $direction=self::SORT_ORDER_DESC)
_init($model, $resourceModel)
addCountryCodeFilter($countryCode)
addRegionCodeFilter($regionCode)
addRegionCodeOrNameFilter($region)