Ekdant-Online-Store/extension/opencart/catalog/model/module/latest.php
2024-08-06 18:06:00 +05:45

30 lines
1.2 KiB
PHP

<?php
namespace Opencart\Catalog\Model\Extension\Opencart\Module;
/**
* Class Latest
*
* @package
*/
class Latest extends \Opencart\Catalog\Model\Catalog\Product {
/**
* @param int $limit
*
* @return array
*/
public function getLatest(int $limit): array {
$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;
$product_data = $this->cache->get('product.' . md5($sql));
if (!$product_data) {
$query = $this->db->query($sql);
$product_data = $query->rows;
$this->cache->set('product.' . md5($sql), $product_data);
}
return (array)$product_data;
}
}