| 1: | <?php
|
| 2: | namespace Opencart\Catalog\Model\Checkout;
|
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: |
|
| 8: | class VoucherTheme extends \Opencart\System\Engine\Model {
|
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: |
|
| 16: | public function getVoucherTheme(int $voucher_theme_id): array {
|
| 17: | $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "voucher_theme` `vt` LEFT JOIN `" . DB_PREFIX . "voucher_theme_description` `vtd` ON (`vt`.`voucher_theme_id` = `vtd`.`voucher_theme_id`) WHERE `vt`.`voucher_theme_id` = '" . (int)$voucher_theme_id . "' AND `vtd`.`language_id` = '" . (int)$this->config->get('config_language_id') . "'");
|
| 18: |
|
| 19: | return $query->row;
|
| 20: | }
|
| 21: |
|
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | |
| 28: |
|
| 29: | public function getVoucherThemes(array $data = []): array {
|
| 30: | $sql = "SELECT * FROM `" . DB_PREFIX . "voucher_theme` `vt` LEFT JOIN `" . DB_PREFIX . "voucher_theme_description` `vtd` ON (`vt`.`voucher_theme_id` = `vtd`.`voucher_theme_id`) WHERE `vtd`.`language_id` = '" . (int)$this->config->get('config_language_id') . "' ORDER BY `vtd`.`name`";
|
| 31: |
|
| 32: | if (isset($data['order']) && ($data['order'] == 'DESC')) {
|
| 33: | $sql .= " DESC";
|
| 34: | } else {
|
| 35: | $sql .= " ASC";
|
| 36: | }
|
| 37: |
|
| 38: | if (isset($data['start']) || isset($data['limit'])) {
|
| 39: | if ($data['start'] < 0) {
|
| 40: | $data['start'] = 0;
|
| 41: | }
|
| 42: |
|
| 43: | if ($data['limit'] < 1) {
|
| 44: | $data['limit'] = 20;
|
| 45: | }
|
| 46: |
|
| 47: | $sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
|
| 48: | }
|
| 49: |
|
| 50: | $key = md5($sql);
|
| 51: |
|
| 52: | $voucher_theme_data = $this->cache->get('voucher_theme.' . $key);
|
| 53: |
|
| 54: | if (!$voucher_theme_data) {
|
| 55: | $query = $this->db->query($sql);
|
| 56: |
|
| 57: | $voucher_theme_data = $query->rows;
|
| 58: |
|
| 59: | $this->cache->set('voucher_theme.' . $key, $voucher_theme_data);
|
| 60: | }
|
| 61: |
|
| 62: | return $voucher_theme_data;
|
| 63: | }
|
| 64: | }
|
| 65: | |