Fix total sold count in search-products endpoint

This commit is contained in:
2025-03-09 14:12:32 -04:00
parent 851cc3c4cc
commit 78a0018940

View File

@@ -837,7 +837,7 @@ router.get('/search-products', async (req, res) => {
p.width, p.width,
p.height, p.height,
p.country_of_origin, p.country_of_origin,
p.totalsold AS total_sold, ci.totalsold AS total_sold,
p.datein AS first_received, p.datein AS first_received,
pls.date_sold AS date_last_sold pls.date_sold AS date_last_sold
FROM products p FROM products p
@@ -849,6 +849,7 @@ router.get('/search-products', async (req, res) => {
LEFT JOIN product_categories pc3 ON p.subline = pc3.cat_id LEFT JOIN product_categories pc3 ON p.subline = pc3.cat_id
LEFT JOIN product_categories pc4 ON p.artist = pc4.cat_id LEFT JOIN product_categories pc4 ON p.artist = pc4.cat_id
LEFT JOIN product_last_sold pls ON p.pid = pls.pid LEFT JOIN product_last_sold pls ON p.pid = pls.pid
LEFT JOIN current_inventory ci ON p.pid = ci.pid
${whereClause} ${whereClause}
GROUP BY p.pid GROUP BY p.pid
${isWildcardSearch ? 'ORDER BY p.datein DESC' : ` ${isWildcardSearch ? 'ORDER BY p.datein DESC' : `