1: | <?php
|
2: | namespace Opencart\Catalog\Model\Setting;
|
3: | |
4: | |
5: | |
6: | |
7: |
|
8: | class Setting extends \Opencart\System\Engine\Model {
|
9: | |
10: | |
11: | |
12: | |
13: | |
14: | |
15: |
|
16: | public function getSettings(int $store_id = 0): array {
|
17: | $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "setting` WHERE `store_id` = '" . (int)$store_id . "' OR `store_id` = 0 ORDER BY `store_id` ASC");
|
18: |
|
19: | return $query->rows;
|
20: | }
|
21: |
|
22: | |
23: | |
24: | |
25: | |
26: | |
27: | |
28: | |
29: |
|
30: | public function getSetting(string $code, int $store_id = 0): array {
|
31: | $setting_data = [];
|
32: |
|
33: | $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "setting` WHERE `store_id` = '" . (int)$store_id . "' AND `code` = '" . $this->db->escape($code) . "'");
|
34: |
|
35: | foreach ($query->rows as $result) {
|
36: | if (!$result['serialized']) {
|
37: | $setting_data[$result['key']] = $result['value'];
|
38: | } else {
|
39: | $setting_data[$result['key']] = json_decode($result['value'], true);
|
40: | }
|
41: | }
|
42: |
|
43: | return $setting_data;
|
44: | }
|
45: |
|
46: | |
47: | |
48: | |
49: | |
50: | |
51: | |
52: | |
53: |
|
54: | public function getValue(string $key, int $store_id = 0): string {
|
55: | $query = $this->db->query("SELECT `value` FROM `" . DB_PREFIX . "setting` WHERE `store_id` = '" . (int)$store_id . "' AND `key` = '" . $this->db->escape($key) . "'");
|
56: |
|
57: | if ($query->num_rows) {
|
58: | return $query->row['value'];
|
59: | } else {
|
60: | return '';
|
61: | }
|
62: | }
|
63: | }
|
64: | |