Рекомендуемые
This commit is contained in:
@@ -924,6 +924,20 @@ class ModelCatalogProduct extends Model {
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getRandomProducts($limit = 5, $exclude = array()) {
|
||||
$sql = "SELECT p.product_id, pd.name FROM " . DB_PREFIX . "product p 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') . "' AND p.status = '1'";
|
||||
|
||||
if (!empty($exclude)) {
|
||||
$sql .= " AND p.product_id NOT IN (" . implode(',', array_map('intval', $exclude)) . ")";
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY RAND() LIMIT " . (int)$limit;
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getTotalProductsByLayoutId($layout_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "product_to_layout WHERE layout_id = '" . (int)$layout_id . "'");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user