Merge pull request #25 from Danakcorp/mrtz

Mrtz
This commit is contained in:
morteza-mortezai
2025-10-26 13:16:01 +03:30
committed by GitHub
2 changed files with 5 additions and 3 deletions
+2 -1
View File
@@ -1673,7 +1673,8 @@ export class ProductRepository extends BaseRepository<IProduct> {
{ {
$match: { $match: {
$expr: { $expr: {
$or: [{ $gt: [{ $size: { $ifNull: ["$variants", []] } }, 0] }, { $eq: ["$category.theme", "noColor_noSize"] }], // $or: [{ $gt: [{ $size: { $ifNull: ["$variants", []] } }, 0] }, { $eq: ["$category.theme", "noColor_noSize"] }],
$gt: [{ $size: { $ifNull: ["$variants", []] } }, 0],
}, },
}, },
}, },
@@ -1614,8 +1614,9 @@ class ProductService {
if (categoryTheme !== CategoryThemeEnum.No_color_No_sized) return true; if (categoryTheme !== CategoryThemeEnum.No_color_No_sized) return true;
const variantCount = product.variants.length; const variantCount = product.variants.length;
if (variantCount && variantCount === 0) return true; console.log("variantCount", variantCount);
if (!variantCount) return true;
console.log("pro", product, categoryTheme);
throw new BadRequestError(ProductMessage.ProductWithNoVariantCategoryTheme); throw new BadRequestError(ProductMessage.ProductWithNoVariantCategoryTheme);
} }