most importantly: new category and filter on is_new

This commit is contained in:
Daniel Goc
2026-04-13 15:29:21 +02:00
parent 7f05d39b38
commit ce4cadaa16
14 changed files with 159 additions and 189 deletions

View File

@@ -116,7 +116,19 @@ func (repo *ProductsRepo) Find(langID uint, userID uint, p find.Paging, filt *fi
p.reference AS reference,
COALESCE(v.variants_number, 0) AS variants_number,
sa.quantity AS quantity,
COALESCE(f.is_favorite, 0) AS is_favorite
COALESCE(f.is_favorite, 0) AS is_favorite,
CASE
WHEN ps.date_add >= DATE_SUB(
NOW(),
INTERVAL (
SELECT value
FROM ps_configuration
WHERE name = 'PS_NB_DAYS_NEW_PRODUCT'
) DAY
) AND ps.active = 1
THEN 1
ELSE 0
END AS is_new
`, config.Get().Image.ImagePrefix).
Joins("JOIN "+dbmodel.PsProductCols.IDProduct.Tab()+" p ON p.id_product = ps.id_product").
Joins("JOIN ps_product_lang pl ON pl.id_product = ps.id_product AND pl.id_lang = ?", langID).