Back to Opencart

File extension\opencart\catalog\model\module\latest.php

docs/api/source-extension.opencart.catalog.model.module.latest.html

4.1.0.34.8 KB
Original Source

Namespaces

Classes

| 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