1: | <?php
2: | namespace Opencart\Catalog\Model\Localisation;
3: | /**
4: | * Class ReturnReason
5: | *
6: | * @package Opencart\Catalog\Model\Localisation
7: | */
8: | class ReturnReason extends \Opencart\System\Engine\Model {
9: | /**
10: | * Get Return Reasons
11: | *
12: | * @param array<string, mixed> $data
13: | *
14: | * @return array<int, array<string, mixed>>
15: | */
16: | public function getReturnReasons(array $data = []): array {
17: | $sql = "SELECT * FROM `" . DB_PREFIX . "return_reason` WHERE `language_id` = '" . (int)$this->config->get('config_language_id') . "' ORDER BY `name`";
18: |
19: | if (isset($data['return']) && ($data['return'] == 'DESC')) {
20: | $sql .= " DESC";
21: | } else {
22: | $sql .= " ASC";
23: | }
24: |
25: | if (isset($data['start']) || isset($data['limit'])) {
26: | if ($data['start'] < 0) {
27: | $data['start'] = 0;
28: | }
29: |
30: | if ($data['limit'] < 1) {
31: | $data['limit'] = 20;
32: | }
33: |
34: | $sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
35: | }
36: |
37: | $key = md5($sql);
38: |
39: | $return_reason_data = $this->cache->get('return_reason.' . $key);
40: |
41: | if (!$return_reason_data) {
42: | $query = $this->db->query($sql);
43: |
44: | $return_reason_data = $query->rows;
45: |
46: | $this->cache->set('return_reason.' . $key, $return_reason_data);
47: | }
48: |
49: | return $return_reason_data;
50: | }
51: | }
52: |

OpenCart API API documentation generated by ApiGen dev-master