1: | <?php
2: | namespace Opencart\Catalog\Model\Localisation;
3: | /**
4: | * Class Zone
5: | *
6: | * @package Opencart\Catalog\Model\Localisation
7: | */
8: | class Zone extends \Opencart\System\Engine\Model {
9: | /**
10: | * Get Zone
11: | *
12: | * @param int $zone_id
13: | *
14: | * @return array<string, mixed>
15: | */
16: | public function getZone(int $zone_id): array {
17: | $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone` WHERE `zone_id` = '" . (int)$zone_id . "' AND `status` = '1'");
18: |
19: | return $query->row;
20: | }
21: |
22: | /**
23: | * Get Zones By Country ID
24: | *
25: | * @param int $country_id
26: | *
27: | * @return array<int, array<string, mixed>>
28: | */
29: | public function getZonesByCountryId(int $country_id): array {
30: | $sql = "SELECT * FROM `" . DB_PREFIX . "zone` WHERE `country_id` = '" . (int)$country_id . "' AND `status` = '1' ORDER BY `name`";
31: |
32: | $key = md5($sql);
33: |
34: | $zone_data = $this->cache->get('zone.' . $key);
35: |
36: | if (!$zone_data) {
37: | $query = $this->db->query($sql);
38: |
39: | $zone_data = $query->rows;
40: |
41: | $this->cache->set('zone.' . $key, $zone_data);
42: | }
43: |
44: | return $zone_data;
45: | }
46: | }
47: |

OpenCart API API documentation generated by ApiGen dev-master