1: | <?php
|
2: | namespace Opencart\Catalog\Model\Cms;
|
3: | |
4: | |
5: | |
6: | |
7: |
|
8: | class Topic extends \Opencart\System\Engine\Model {
|
9: | |
10: | |
11: | |
12: | |
13: | |
14: | |
15: |
|
16: | public function getTopic(int $topic_id): array {
|
17: | $sql = "SELECT DISTINCT * FROM `" . DB_PREFIX . "topic` `t` LEFT JOIN `" . DB_PREFIX . "topic_description` `td` ON (`t`.`topic_id` = `td`.`topic_id`) LEFT JOIN `" . DB_PREFIX . "topic_to_store` `t2s` ON (`t`.`topic_id` = `t2s`.`topic_id`) WHERE `t`.`topic_id` = '" . (int)$topic_id . "' AND `td`.`language_id` = '" . (int)$this->config->get('config_language_id') . "' AND `t2s`.`store_id` = '" . (int)$this->config->get('config_store_id') . "' AND `t`.`status` = '1'";
|
18: |
|
19: | $topic_data = $this->cache->get('topic.' . md5($sql));
|
20: |
|
21: | if (!$topic_data) {
|
22: | $query = $this->db->query($sql);
|
23: |
|
24: | $topic_data = $query->row;
|
25: |
|
26: | $this->cache->set('topic.' . md5($sql), $topic_data);
|
27: | }
|
28: |
|
29: | return $topic_data;
|
30: | }
|
31: |
|
32: | |
33: | |
34: | |
35: | |
36: |
|
37: | public function getTopics(): array {
|
38: | $sql = "SELECT * FROM `" . DB_PREFIX . "topic` `t` LEFT JOIN `" . DB_PREFIX . "topic_description` `td` ON (`t`.`topic_id` = `td`.`topic_id`) LEFT JOIN `" . DB_PREFIX . "topic_to_store` `t2s` ON (`t`.`topic_id` = `t2s`.`topic_id`) WHERE `td`.`language_id` = '" . (int)$this->config->get('config_language_id') . "' AND `t2s`.`store_id` = '" . (int)$this->config->get('config_store_id') . "' AND `t`.`status` = '1' ORDER BY `t`.`sort_order` DESC";
|
39: |
|
40: | $key = md5($sql);
|
41: |
|
42: | $topic_data = $this->cache->get('topic.' . $key);
|
43: |
|
44: | if (!$topic_data) {
|
45: | $query = $this->db->query($sql);
|
46: |
|
47: | $topic_data = $query->rows;
|
48: |
|
49: | $this->cache->set('topic.' . $key, $topic_data);
|
50: | }
|
51: |
|
52: | return $topic_data;
|
53: | }
|
54: | }
|
55: | |