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

OpenCart API API documentation generated by ApiGen dev-master