Product editor search enhancements
This commit is contained in:
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user