Public Member Functions | |
toOptionArray ($isMultiselect=false) | |
sortRegionCountries ($a, $b) | |
Protected Attributes | |
$_countries | |
$_options |
Definition at line 28 of file Allregion.php.
sortRegionCountries | ( | $ | a, | |
$ | b | |||
) |
toOptionArray | ( | $ | isMultiselect = false |
) |
Definition at line 33 of file Allregion.php.
00034 { 00035 if (!$this->_options) { 00036 $countriesArray = Mage::getResourceModel('directory/country_collection')->load() 00037 ->toOptionArray(false); 00038 $this->_countries = array(); 00039 foreach ($countriesArray as $a) { 00040 $this->_countries[$a['value']] = $a['label']; 00041 } 00042 00043 $countryRegions = array(); 00044 $regionsCollection = Mage::getResourceModel('directory/region_collection')->load(); 00045 foreach ($regionsCollection as $region) { 00046 $countryRegions[$region->getCountryId()][$region->getId()] = $region->getDefaultName(); 00047 } 00048 uksort($countryRegions, array($this, 'sortRegionCountries')); 00049 00050 $this->_options = array(); 00051 foreach ($countryRegions as $countryId=>$regions) { 00052 $regionOptions = array(); 00053 foreach ($regions as $regionId=>$regionName) { 00054 $regionOptions[] = array('label'=>$regionName, 'value'=>$regionId); 00055 } 00056 $this->_options[] = array('label'=>$this->_countries[$countryId], 'value'=>$regionOptions); 00057 } 00058 } 00059 $options = $this->_options; 00060 if(!$isMultiselect){ 00061 array_unshift($options, array('value'=>'', 'label'=>'')); 00062 } 00063 00064 return $options; 00065 }
$_countries [protected] |
Definition at line 30 of file Allregion.php.
$_options [protected] |
Definition at line 31 of file Allregion.php.