the meili search endpoint

This commit is contained in:
Daniel Goc
2026-03-24 11:15:09 +01:00
parent bfc488bad8
commit 04538d4373
6 changed files with 188 additions and 44 deletions

View File

@@ -80,7 +80,6 @@ func (r *ProductDescriptionRepo) GetMeiliProducts(id_lang uint) ([]model.MeiliSe
var products []model.MeiliSearchProduct
err := db.DB.
Select("pl.`usage` AS `usage`").
Select(`
ps.id_product AS id_product,
pl.name AS name,
@@ -88,17 +87,24 @@ func (r *ProductDescriptionRepo) GetMeiliProducts(id_lang uint) ([]model.MeiliSe
ps.price AS price,
pl.description AS description,
pl.description_short AS description_short,
pl.usage AS used_for,
p.ean13 AS ean13,
p.reference AS reference,
p.width AS width,
p.height AS height,
p.depth AS depth,
p.weight AS weight
p.weight AS weight,
ps.id_category_default AS id_category,
cl.name AS category_name,
COUNT(DISTINCT pas.id_product_attribute) AS variations
`).
Table("ps_product_shop AS ps").
Joins("LEFT JOIN ps_product_lang AS pl ON ps.id_product = pl.id_product AND pl.id_shop = ? AND pl.id_lang = ?", constdata.SHOP_ID, id_lang).
Joins("LEFT JOIN ps_product AS p ON p.id_product = ps.id_product").
Joins("LEFT JOIN ps_category_lang AS cl ON cl.id_category = ps.id_category_default AND cl.id_shop = ? AND cl.id_lang = ?", constdata.SHOP_ID, id_lang).
Joins("LEFT JOIN ps_product_attribute_shop AS pas ON pas.id_product = ps.id_product AND pas.id_shop = ?", constdata.SHOP_ID).
Where("ps.id_shop = ?", constdata.SHOP_ID).
Group("ps.id_product").
Scan(&products).Error
if err != nil {
return products, fmt.Errorf("database error: %w", err)