Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. directory_country_region
  2.  
  3. public function getcitiesAction()
  4. {
  5. if (!$this->getRequest()->isXmlHttpRequest()) {
  6. return;
  7. }
  8.  
  9. $regionId = (int)$this->getRequest()->getParam('region_id');
  10. $countryId = $this->getRequest()->getParam('country_id');
  11.  
  12. if (!$regionId || !$countryId) {
  13. return;
  14. }
  15.  
  16. echo Mage::helper('your data helper')->getCities($countryId, $regionId);
  17.  
  18. return;
  19. }
  20.  
  21. public function getLocalityAction()
  22. {
  23. if (!$this->getRequest()->isXmlHttpRequest()) {
  24. return;
  25. }
  26.  
  27. $cityId = (int)$this->getRequest()->getParam('city_id');
  28.  
  29.  
  30. if (!cityId ) {
  31. return;
  32. }
  33.  
  34. echo Mage::helper('your data helper')->getlocalities($cityId);
  35.  
  36. return;
  37. }
  38.  
  39. public function getCities($countryId, $regionId)
  40. {
  41. $cityCollection = Mage::getModel('your city model')->getCollection();
  42. $cityCollection->addFieldToSelect('cityname')
  43. ->addFieldToFilter('country_id', $countryId)
  44. ->addFieldToFilter('region_id', $regionId);
  45.  
  46. $jsonData = Mage::helper('core')->jsonEncode($cityCollection->getData());
  47.  
  48. return $jsonData;
  49. }
  50.  
  51.  
  52. public function getlocalities($cityId)
  53. {
  54. $localityCollection = Mage::getModel('your locality model')->getCollection();
  55. $cityCollection->addFieldToSelect('locality_name')
  56. ->addFieldToFilter('city_id', $cityId)
  57.  
  58.  
  59. $jsonData = Mage::helper('core')->jsonEncode($localityCollection ->getData());
  60.  
  61. return $jsonData;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement