Add search for products in all sub categories (#68)
This commit is contained in:
@@ -121,7 +121,32 @@ export function categoryProducts(categoryId: number) {
|
||||
return (
|
||||
baseQuery +
|
||||
/* sql */ `
|
||||
WHERE products.productid IN (SELECT product_id FROM product_category WHERE category_id = ${categoryId});
|
||||
WHERE products.productid IN (SELECT product_id FROM product_category WHERE category_id = ${categoryId})
|
||||
ORDER BY products.inserted DESC
|
||||
`
|
||||
);
|
||||
}
|
||||
|
||||
export function categoryWithAllSubCategoriesProducts(categoryId: number) {
|
||||
return (
|
||||
baseQuery +
|
||||
/* sql */ `
|
||||
WHERE products.productid IN (
|
||||
SELECT product_id
|
||||
FROM product_category
|
||||
WHERE category_id IN (
|
||||
SELECT cat.id
|
||||
FROM categories cat
|
||||
JOIN (
|
||||
SELECT id, lft, rgt
|
||||
FROM categories
|
||||
WHERE id = ${categoryId}
|
||||
) tree
|
||||
ON cat.lft >= tree.lft AND cat.rgt <= tree.rgt
|
||||
)
|
||||
ORDER BY product_id
|
||||
)
|
||||
ORDER BY products.inserted DESC
|
||||
`
|
||||
);
|
||||
}
|
||||
@@ -130,7 +155,8 @@ export function designerProducts() {
|
||||
return (
|
||||
baseQuery +
|
||||
/* sql */ `
|
||||
WHERE products.designerid = ?;
|
||||
WHERE products.designerid = ?
|
||||
ORDER BY products.inserted DESC
|
||||
`
|
||||
);
|
||||
}
|
||||
@@ -139,7 +165,8 @@ export function keywordProducts(keywordId: number) {
|
||||
return (
|
||||
baseQuery +
|
||||
/* sql */ `
|
||||
WHERE products.productid IN (SELECT product_id FROM product_keyword WHERE keyword_id = ${keywordId});
|
||||
WHERE products.productid IN (SELECT product_id FROM product_keyword WHERE keyword_id = ${keywordId})
|
||||
ORDER BY products.inserted DESC
|
||||
`
|
||||
);
|
||||
}
|
||||
@@ -148,7 +175,8 @@ export function searchByFieldValue(fieldid: number) {
|
||||
return (
|
||||
baseQuery +
|
||||
/* sql */ `
|
||||
WHERE products.productid IN (SELECT productid FROM "product-products_fields" WHERE fieldid = ${fieldid} AND LOWER(value) LIKE ? LIMIT 5000); -- limit to 5000 results
|
||||
WHERE products.productid IN (SELECT productid FROM "product-products_fields" WHERE fieldid = ${fieldid} AND LOWER(value) LIKE ? LIMIT 5000) -- limit to 5000 results
|
||||
ORDER BY products.inserted DESC
|
||||
`
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user