1: | <?php
2: | namespace Opencart\Catalog\Model\Extension\Opencart\Module;
3: | /**
4: | * Class Latest
5: | *
6: | * @package Opencart\Catalog\Model\Extension\Opencart\Module
7: | */
8: | class Latest extends \Opencart\Catalog\Model\Catalog\Product {
9: | /**
10: | * Get Latest
11: | *
12: | * @param int $limit
13: | *
14: | * @return array<int, array<string, mixed>>
15: | */
16: | public function getLatest(int $limit): array {
17: | $sql = "SELECT DISTINCT *, `pd`.`name`, `p`.`image`, " . $this->statement['discount'] . ", " . $this->statement['special'] . ", " . $this->statement['reward'] . ", " . $this->statement['review'] . " FROM `" . DB_PREFIX . "product_to_store` `p2s` LEFT JOIN `" . DB_PREFIX . "product` `p` ON (`p`.`product_id` = `p2s`.`product_id` AND `p2s`.`store_id` = '" . (int)$this->config->get('config_store_id') . "' AND `p`.`status` = '1' AND `p`.`date_available` <= NOW()) LEFT JOIN `" . DB_PREFIX . "product_description` `pd` ON (`p`.`product_id` = `pd`.`product_id`) WHERE `pd`.`language_id` = '" . (int)$this->config->get('config_language_id') . "' ORDER BY `p`.`date_added` DESC LIMIT 0," . (int)$limit;
18: |
19: | $key = md5($sql);
20: |
21: | $product_data = $this->cache->get('product.' . $key);
22: |
23: | if (!$product_data) {
24: | $query = $this->db->query($sql);
25: |
26: | $product_data = $query->rows;
27: |
28: | $this->cache->set('product.' . $key, $product_data);
29: | }
30: |
31: | return (array)$product_data;
32: | }
33: | }
34: |

OpenCart API API documentation generated by ApiGen dev-master