docs/api/source-catalog.model.cms.topic.html
| 1: | <?php |
| 2: | namespace Opencart\Catalog\Model\Cms; |
| 3: | /** |
| 4: | * Class Topic |
| 5: | * |
| 6: | * @package Opencart\Catalog\Model\Cms |
| 7: | */ |
| 8: | class Topic extends \Opencart\System\Engine\Model { |
| 9: | /** |
| 10: | * Get Topic |
| 11: | * |
| 12: | * @param int $topic_id |
| 13: | * |
| 14: | * @return array<int, array<string, mixed>> |
| 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: | * Get Topics |
| 34: | * |
| 35: | * @return array<int, array<string, mixed>> |
| 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: | |
OpenCart API API documentation generated by ApiGen dev-master