Product editor search enhancements

This commit is contained in:
2026-03-11 15:23:03 -04:00
parent c344fdc3b8
commit f887dc6af1
4 changed files with 193 additions and 60 deletions
+10 -1
View File
@@ -1058,7 +1058,16 @@ router.get('/search-products', async (req, res) => {
// Build WHERE clause with additional filters
let whereClause;
if (pid) {
whereClause = `\n WHERE p.pid = ${connection.escape(Number(pid))}`;
const pids = String(pid).split(',').map(Number).filter(n => !isNaN(n) && n > 0);
if (pids.length === 0) {
connection.release();
return res.status(400).json({ error: 'Invalid pid parameter' });
}
if (pids.length === 1) {
whereClause = `\n WHERE p.pid = ${connection.escape(pids[0])}`;
} else {
whereClause = `\n WHERE p.pid IN (${pids.map(p => connection.escape(p)).join(',')})`;
}
} else {
whereClause = `
WHERE (