Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- directory_country_region
- public function getcitiesAction()
- {
- if (!$this->getRequest()->isXmlHttpRequest()) {
- return;
- }
- $regionId = (int)$this->getRequest()->getParam('region_id');
- $countryId = $this->getRequest()->getParam('country_id');
- if (!$regionId || !$countryId) {
- return;
- }
- echo Mage::helper('your data helper')->getCities($countryId, $regionId);
- return;
- }
- public function getLocalityAction()
- {
- if (!$this->getRequest()->isXmlHttpRequest()) {
- return;
- }
- $cityId = (int)$this->getRequest()->getParam('city_id');
- if (!cityId ) {
- return;
- }
- echo Mage::helper('your data helper')->getlocalities($cityId);
- return;
- }
- public function getCities($countryId, $regionId)
- {
- $cityCollection = Mage::getModel('your city model')->getCollection();
- $cityCollection->addFieldToSelect('cityname')
- ->addFieldToFilter('country_id', $countryId)
- ->addFieldToFilter('region_id', $regionId);
- $jsonData = Mage::helper('core')->jsonEncode($cityCollection->getData());
- return $jsonData;
- }
- public function getlocalities($cityId)
- {
- $localityCollection = Mage::getModel('your locality model')->getCollection();
- $cityCollection->addFieldToSelect('locality_name')
- ->addFieldToFilter('city_id', $cityId)
- $jsonData = Mage::helper('core')->jsonEncode($localityCollection ->getData());
- return $jsonData;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement