Fix: filter sub categories
This commit is contained in:
parent
819c59f28f
commit
892ec58c6a
|
@ -296,8 +296,15 @@ export class ProductService {
|
||||||
subCategories: string,
|
subCategories: string,
|
||||||
username: string,
|
username: string,
|
||||||
) {
|
) {
|
||||||
|
let filterSubCategories;
|
||||||
const user = await this.usersService.findOneByUsername(username);
|
const user = await this.usersService.findOneByUsername(username);
|
||||||
|
|
||||||
|
if (subCategories) {
|
||||||
|
filterSubCategories = subCategories.split(',').map((data) => {
|
||||||
|
return data.trim();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (user.partner === null) {
|
if (user.partner === null) {
|
||||||
throw new HttpException(
|
throw new HttpException(
|
||||||
{
|
{
|
||||||
|
@ -332,13 +339,19 @@ export class ProductService {
|
||||||
'(current_price.price + current_price.mark_up_price) as price',
|
'(current_price.price + current_price.mark_up_price) as price',
|
||||||
);
|
);
|
||||||
|
|
||||||
if (
|
// if (
|
||||||
subCategories != 'null' &&
|
// subCategories != 'null' &&
|
||||||
subCategories &&
|
// subCategories &&
|
||||||
subCategories != 'undefined'
|
// subCategories != 'undefined'
|
||||||
) {
|
// ) {
|
||||||
baseQuery.where('product.sub_categories_id = :id', {
|
// baseQuery.where('product.sub_categories_id = :id', {
|
||||||
id: subCategories,
|
// id: subCategories,
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (subCategories && filterSubCategories.length > 0) {
|
||||||
|
baseQuery.where('product.sub_categories_id IN (:...subCategoryId)', {
|
||||||
|
subCategoryId: filterSubCategories,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user