36 \
Magento\Framework\Locale\ResolverInterface $localeResolver,
40 $this->_localeResolver = $localeResolver;
50 $this->
_init(
'directory_country_region',
'region_id');
51 $this->_regionNameTable = $this->
getTable(
'directory_country_region_name');
67 $locale = $this->_localeResolver->getLocale();
72 $condition =
$connection->quoteInto(
'lrn.locale = ?', $locale);
74 [
'lrn' => $this->_regionNameTable],
75 "{$regionField} = lrn.region_id AND {$condition}",
79 if ($locale != $systemLocale) {
80 $nameExpr =
$connection->getCheckSql(
'lrn.region_id is null',
'srn.name',
'lrn.name');
81 $condition =
$connection->quoteInto(
'srn.locale = ?', $systemLocale);
83 [
'srn' => $this->_regionNameTable],
84 "{$regionField} = srn.region_id AND {$condition}",
88 $select->columns([
'name'],
'lrn');
106 $locale = $this->_localeResolver->getLocale();
107 $joinCondition =
$connection->quoteInto(
'rname.region_id = region.region_id AND rname.locale = ?', $locale);
111 [
'rname' => $this->_regionNameTable],
115 'region.country_id = ?',
118 "region.{$field} = ?",
124 $object->setData(
$data);
143 return $this->
_loadByCountry($region, $countryId, (
string)$regionCode,
'code');
156 return $this->
_loadByCountry($region, $countryId, (
string)$regionName,
'default_name');
_getLoadSelect($field, $value, $object)
loadByCode(\Magento\Directory\Model\Region $region, $regionCode, $countryId)
_init($mainTable, $idFieldName)
loadByName(\Magento\Directory\Model\Region $region, $regionName, $countryId)
_loadByCountry($object, $countryId, $value, $field)
__construct(\Magento\Framework\Model\ResourceModel\Db\Context $context, \Magento\Framework\Locale\ResolverInterface $localeResolver, $connectionName=null)
_afterLoad(\Magento\Framework\Model\AbstractModel $object)