Public Member Functions | |
getLoadrRegionUrl () | |
getCountryCollection () | |
getCountryHtmlSelect ($defValue=null, $name='country_id', $id='country', $title='Country') | |
getRegionCollection () | |
getRegionHtmlSelect () | |
getCountryId () | |
getRegionsJs () |
Definition at line 34 of file Data.php.
getCountryCollection | ( | ) |
Definition at line 41 of file Data.php.
00042 { 00043 $collection = $this->getData('country_collection'); 00044 if (is_null($collection)) { 00045 $collection = Mage::getModel('directory/country')->getResourceCollection() 00046 ->loadByStore(); 00047 $this->setData('country_collection', $collection); 00048 } 00049 00050 return $collection; 00051 }
getCountryHtmlSelect | ( | $ | defValue = null , |
|
$ | name = 'country_id' , |
|||
$ | id = 'country' , |
|||
$ | title = 'Country' | |||
) |
Definition at line 53 of file Data.php.
00054 { 00055 Varien_Profiler::start('TEST: '.__METHOD__); 00056 if (is_null($defValue)) { 00057 $defValue = $this->getCountryId(); 00058 } 00059 $cacheKey = 'DIRECTORY_COUNTRY_SELECT_STORE_'.Mage::app()->getStore()->getCode(); 00060 if (Mage::app()->useCache('config') && $cache = Mage::app()->loadCache($cacheKey)) { 00061 $options = unserialize($cache); 00062 } else { 00063 $options = $this->getCountryCollection()->toOptionArray(); 00064 if (Mage::app()->useCache('config')) { 00065 Mage::app()->saveCache(serialize($options), $cacheKey, array('config')); 00066 } 00067 } 00068 $html = $this->getLayout()->createBlock('core/html_select') 00069 ->setName($name) 00070 ->setId($id) 00071 ->setTitle(Mage::helper('directory')->__($title)) 00072 ->setClass('validate-select') 00073 ->setValue($defValue) 00074 ->setOptions($options) 00075 ->getHtml(); 00076 00077 Varien_Profiler::stop('TEST: '.__METHOD__); 00078 return $html; 00079 }
getCountryId | ( | ) |
Reimplemented in Mage_Customer_Block_Address_Edit, and Mage_Customer_Block_Form_Register.
Definition at line 119 of file Data.php.
00120 { 00121 $countryId = $this->getData('country_id'); 00122 if (is_null($countryId)) { 00123 $countryId = Mage::getStoreConfig('general/country/default'); 00124 } 00125 return $countryId; 00126 }
getLoadrRegionUrl | ( | ) |
getRegionCollection | ( | ) |
Definition at line 81 of file Data.php.
00082 { 00083 $collection = $this->getData('region_collection'); 00084 if (is_null($collection)) { 00085 $collection = Mage::getModel('directory/region')->getResourceCollection() 00086 ->addCountryFilter($this->getCountryId()) 00087 ->load(); 00088 00089 $this->setData('region_collection', $collection); 00090 } 00091 return $collection; 00092 }
getRegionHtmlSelect | ( | ) |
Definition at line 95 of file Data.php.
00096 { 00097 Varien_Profiler::start('TEST: '.__METHOD__); 00098 $cacheKey = 'DIRECTORY_REGION_SELECT_STORE'.Mage::app()->getStore()->getId(); 00099 if (Mage::app()->useCache('config') && $cache = Mage::app()->loadCache($cacheKey)) { 00100 $options = unserialize($cache); 00101 } else { 00102 $options = $this->getRegionCollection()->toOptionArray(); 00103 if (Mage::app()->useCache('config')) { 00104 Mage::app()->saveCache(serialize($options), $cacheKey, array('config')); 00105 } 00106 } 00107 $html = $this->getLayout()->createBlock('core/html_select') 00108 ->setName('region') 00109 ->setTitle(Mage::helper('directory')->__('State/Province')) 00110 ->setId('state') 00111 ->setClass('required-entry validate-state') 00112 ->setValue($this->getRegionId()) 00113 ->setOptions($options) 00114 ->getHtml(); 00115 Varien_Profiler::start('TEST: '.__METHOD__); 00116 return $html; 00117 }
getRegionsJs | ( | ) |
Definition at line 128 of file Data.php.
00129 { 00130 Varien_Profiler::start('TEST: '.__METHOD__); 00131 $regionsJs = $this->getData('regions_js'); 00132 if (!$regionsJs) { 00133 $countryIds = array(); 00134 foreach ($this->getCountryCollection() as $country) { 00135 $countryIds[] = $country->getCountryId(); 00136 } 00137 $collection = Mage::getModel('directory/region')->getResourceCollection() 00138 ->addCountryFilter($countryIds) 00139 ->load(); 00140 $regions = array(); 00141 foreach ($collection as $region) { 00142 if (!$region->getRegionId()) { 00143 continue; 00144 } 00145 $regions[$region->getCountryId()][$region->getRegionId()] = array( 00146 'code'=>$region->getCode(), 00147 'name'=>$region->getName() 00148 ); 00149 } 00150 $regionsJs = Zend_Json::encode($regions); 00151 } 00152 Varien_Profiler::stop('TEST: '.__METHOD__); 00153 return $regionsJs; 00154 }