Рекомендуемые

This commit is contained in:
Konstantin
2026-05-30 14:59:49 +03:00
parent 0e8a0f3b0c
commit 6a847ab7b5
4 changed files with 80 additions and 0 deletions
+14
View File
@@ -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 . "'");