public function loadByName(Mage_Directory_Model_Region $region, $regionName, $countryId) { $locale = Mage::app()->getLocale()->getLocaleCode(); $select = $this->_read->select()->from(array('region' => $this->_regionTable))->where('region.country_id=?', $countryId)->where('region.default_name=?', $regionName)->join(array('rname' => $this->_regionNameTable), 'rname.region_id=region.region_id AND rname.locale=\'' . $locale . '\'', array('name')); $region->setData($this->_read->fetchRow($select)); return $this; }
/** * Return list of country's regions as array * * @param bool $noEmpty * @param null|string $country * @return array */ public function toOptionArray($noEmpty = false, $country = null) { $options = $this->_optionsModel->getCollection()->addCountryFilter($country)->toOptionArray(); if ($noEmpty) { unset($options[0]); } else { if ($options) { $options[0] = array('value' => '0', 'label' => '*'); } else { $options = array(array('value' => '0', 'label' => '*')); } } return $options; }
public function getRegion() { if (!$this->getCountry()->getId()) { return NULL; } if (is_null($this->region)) { $countryRegions = $this->getCountry()->getRegionCollection(); $countryRegions->getSelect()->where('code = ? OR default_name = ?', $this->getState()); $this->region = $countryRegions->getFirstItem(); if ($this->isRegionValidationRequired() && !$this->region->getId()) { throw new Ess_M2ePro_Model_Exception(sprintf('State/Region "%s" in the shipping address is invalid.', $this->getState())); } } return $this->region; }