docs/api/source-extension.opencart.catalog.model.module.bestseller.html
| 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