Merge pull request #69 from Danakcorp/mrtz

product vriants bug
This commit is contained in:
morteza-mortezai
2025-11-29 15:17:45 +03:30
committed by GitHub
14 changed files with 86 additions and 590 deletions
+1 -3
View File
@@ -66,9 +66,7 @@ export const IOCTYPES = {
WarrantyRepository: Symbol.for("WarrantyRepository"),
ShipmentRepository: Symbol.for("ShipmentRepository"),
TokenRepository: Symbol.for("TokenRepository"),
ColorRepository: Symbol.for("ColorRepository"),
SizeRepository: Symbol.for("SizeRepository"),
MeterageRepository: Symbol.for("MeterageRepository"),
ThemeRepository: Symbol.for("ThemeRepository"),
ThemeValueRepository: Symbol.for("ThemeValueRepository"),
QuestionRepository: Symbol.for("QuestionRepository"),
@@ -87,9 +87,7 @@ export class AdminCategoryController extends BaseController {
@ApiResponse("successful", HttpStatus.Created)
@ApiParam("id", "id of category", true)
@ApiModel(CreateCategoryThemeDTO)
@ApiBody(
"the colors and sizes and meterage fields are optional and one of them should send and u can also send noColor_noSize too for no theme",
)
@ApiBody("the ")
@ApiAuth()
@httpPost(
"/:id/variants",
+3 -11
View File
@@ -20,11 +20,7 @@ class CartRepository extends BaseRepository<ICart> {
})
.populate({
path: "items.variant",
populate: [
{ path: "warranty" },
{ path: "shop" },
{ path: "themeValue" },
],
populate: [{ path: "warranty" }, { path: "shop" }, { path: "themeValue" }],
});
}
@@ -235,13 +231,9 @@ class CartRepository extends BaseRepository<ICart> {
{ $lookup: { from: "productvariants", localField: "items.variant", foreignField: "_id", as: "variantDetails" } },
{ $unwind: "$variantDetails" },
{ $lookup: { from: "warranties", localField: "variantDetails.warranty", foreignField: "_id", as: "variantDetails.warranty" } },
{ $lookup: { from: "colors", localField: "variantDetails.color", foreignField: "_id", as: "variantDetails.color" } },
{ $lookup: { from: "sizes", localField: "variantDetails.size", foreignField: "_id", as: "variantDetails.size" } },
{ $lookup: { from: "meterages", localField: "variantDetails.meterage", foreignField: "_id", as: "variantDetails.meterage" } },
{ $lookup: { from: "themeValues", localField: "variantDetails.themeValue", foreignField: "_id", as: "variantDetails.themeValue" } },
{ $unwind: { path: "$variantDetails.warranty", preserveNullAndEmptyArrays: true } },
{ $unwind: { path: "$variantDetails.color", preserveNullAndEmptyArrays: true } },
{ $unwind: { path: "$variantDetails.size", preserveNullAndEmptyArrays: true } },
{ $unwind: { path: "$variantDetails.meterage", preserveNullAndEmptyArrays: true } },
{ $unwind: { path: "$variantDetails.themeValue", preserveNullAndEmptyArrays: true } },
{ $lookup: { from: "shops", localField: "variantDetails.shop", foreignField: "_id", as: "variantDetails.shop" } },
{ $unwind: "$variantDetails.shop" },
{
@@ -44,7 +44,7 @@ export class CreateCategoryDTO {
@IsValidId(ThemeModel)
@ApiProperty({
type: "string",
description: "the variation theme of a category ==> should be one of Color/Size/Meterage or noColor_noSize",
description: "the variation theme of a category ==> ",
})
themeId: string;
}
@@ -57,8 +57,7 @@ export class UpdateCategoryDTO {
@IsValidId(ThemeModel)
@ApiProperty({
type: "string",
description: "the variation theme of a category ==> should be one of Color/Size/Meterage or noColor_noSize",
example: "Color",
description: "the variation theme of a category ==> ",
})
themeId: string;
}
+3 -28
View File
@@ -1,42 +1,17 @@
import { Expose, Transform, Type, plainToInstance } from "class-transformer";
import { ThemeValueDTO } from "../../product/DTO/product.dto";
import { ICategory } from "../models/Abstraction/ICategory";
import { ICategoryAttribute } from "../models/Abstraction/ICategoryAttributes";
export class Size_MeterageDTO {
@Expose()
_id: number;
@Expose()
value: string;
}
export class ColorDTO {
@Expose()
_id: number;
@Expose()
name: string;
@Expose()
hexColor: string;
}
export class VariantDTO {
@Expose()
_id: string;
@Expose()
@Type(() => ColorDTO)
@Type(() => ThemeValueDTO)
@Transform(({ value }) => (value && value.length > 0 ? value : undefined) /*, { toClassOnly: true }*/)
colors: ColorDTO[];
@Expose()
@Type(() => Size_MeterageDTO)
@Transform(({ value }) => (value && value.length > 0 ? value : undefined) /*, { toClassOnly: true }*/)
sizes: Size_MeterageDTO[];
@Expose()
@Type(() => Size_MeterageDTO)
@Transform(({ value }) => (value && value.length > 0 ? value : undefined) /*, { toClassOnly: true }*/)
meterages: Size_MeterageDTO[];
themeValues: ThemeValueDTO[];
}
export class CategoryVariantDTO {
@@ -1,34 +1,11 @@
import { PartialType } from "@nestjs/mapped-types";
import { Expose, Type } from "class-transformer";
import { ArrayMinSize, IsHexColor, IsNotEmpty, IsOptional, ValidateNested } from "class-validator";
import { Expose } from "class-transformer";
import { IsOptional } from "class-validator";
import { ApiProperty } from "../../../common/decorator/swggerDocs";
import { IsValidId } from "../../../common/decorator/validation.decorator";
import { ThemeModel } from "../models/theme.model";
export class CreateColorDTO {
@Expose()
@IsNotEmpty()
name: string;
@Expose()
@IsNotEmpty()
@IsHexColor()
hexColor: string;
}
export class CreateSizeDTO {
@Expose()
@IsNotEmpty()
value: string;
}
export class CreateMeterageDTO {
@Expose()
@IsNotEmpty()
value: string;
}
export class CreateCategoryThemeDTO {
@Expose()
@IsOptional()
@@ -38,46 +15,6 @@ export class CreateCategoryThemeDTO {
description: "theme id",
})
themeId?: string;
@Expose()
@IsOptional()
@IsNotEmpty()
@ArrayMinSize(1)
@ValidateNested({ each: true })
@Type(() => CreateColorDTO)
@ApiProperty({
type: "Array",
required: true,
description: "the variation colors of a category theme",
example: [{ name: "مشکی", hexColor: "#000000" }],
})
colors?: CreateColorDTO[];
@Expose()
@IsOptional()
@IsNotEmpty()
@ArrayMinSize(1)
@ValidateNested({ each: true })
@Type(() => CreateSizeDTO)
@ApiProperty({
type: "Array",
description: "the variation sizes of a category theme",
example: [{ value: "M" }, { value: "S" }, { value: "L" }],
})
sizes?: CreateSizeDTO[];
@Expose()
@IsOptional()
@IsNotEmpty()
@ArrayMinSize(1)
@ValidateNested({ each: true })
@Type(() => CreateSizeDTO)
@ApiProperty({
type: "Array",
description: "the variation meterage of a category theme",
example: [{ value: "10" }, { value: "20" }, { value: "50" }],
})
meterages?: CreateMeterageDTO[];
}
export class UpdateCategoryVariantDTO extends PartialType(CreateCategoryThemeDTO) {}
+1 -1
View File
@@ -149,7 +149,7 @@ class CategoryRepository extends BaseRepository<ICategory> {
for (const category of categories) {
if (!category?.theme || !category?.variants.length) continue;
const theme = `${category?.theme}s`.toLowerCase(); // e.g., 'colors', 'sizes', 'meterages'
const theme = `${category?.theme}s`.toLowerCase();
if (!themeVariantsMap.has(theme)) {
themeVariantsMap.set(theme, new Set());
+2 -4
View File
@@ -391,14 +391,12 @@ class CategoryService {
// get category variants
const categoryVariants = await this.categoryRepository.getCategoryVariants(categoryIds);
const colors = categoryVariants?.colors;
const sizes = categoryVariants?.sizes;
const meterages = categoryVariants?.meterages;
const themeValues = categoryVariants?.themeValues;
// fetch products from the category and its children
const { docs, count } = await this.productRepo.getProductsWithCategory(categoryIds, queries, userId);
const products = docs.map((doc: IProduct) => ProductDTO.transformProduct(doc));
const filters = { attributes: catAttributes?.attributes, priceRange, colors, sizes, meterages };
const filters = { attributes: catAttributes?.attributes, priceRange, themeValues };
// fetch category breadcrumb
const breadcrumb = await this.getCategoryBreadcrumb(category._id.toString());
+16 -128
View File
@@ -391,43 +391,15 @@ class OrderRepository extends BaseRepository<IOrder> {
},
{
$lookup: {
from: "colors",
localField: "orderItems.shipmentItems.variant.color",
from: "themeValues",
localField: "orderItems.shipmentItems.variant.themeValue",
foreignField: "_id",
as: "orderItems.shipmentItems.variant.color",
as: "orderItems.shipmentItems.variant.themeValue",
},
},
{
$unwind: {
path: "$orderItems.shipmentItems.variant.color",
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "sizes",
localField: "orderItems.shipmentItems.variant.size",
foreignField: "_id",
as: "orderItems.shipmentItems.variant.size",
},
},
{
$unwind: {
path: "$orderItems.shipmentItems.variant.size",
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "meterages",
localField: "orderItems.shipmentItems.variant.meterage",
foreignField: "_id",
as: "orderItems.shipmentItems.variant.meterage",
},
},
{
$unwind: {
path: "$orderItems.shipmentItems.variant.meterage",
path: "$orderItems.shipmentItems.variant.themeValue",
preserveNullAndEmptyArrays: true,
},
},
@@ -566,43 +538,15 @@ class OrderItemRepo extends BaseRepository<IOrderItem> {
},
{
$lookup: {
from: "colors",
localField: "shipmentItems.variant.color",
from: "themeValues",
localField: "shipmentItems.variant.themeValue",
foreignField: "_id",
as: "shipmentItems.variant.color",
as: "shipmentItems.variant.themeValue",
},
},
{
$unwind: {
path: "$shipmentItems.variant.color",
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "sizes",
localField: "shipmentItems.variant.size",
foreignField: "_id",
as: "shipmentItems.variant.size",
},
},
{
$unwind: {
path: "$shipmentItems.variant.size",
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "meterages",
localField: "shipmentItems.variant.meterage",
foreignField: "_id",
as: "shipmentItems.variant.meterage",
},
},
{
$unwind: {
path: "$shipmentItems.variant.meterage",
path: "$shipmentItems.variant.themeValue",
preserveNullAndEmptyArrays: true,
},
},
@@ -1521,43 +1465,15 @@ class OrderItemRepo extends BaseRepository<IOrderItem> {
},
{
$lookup: {
from: "colors",
localField: "shipmentItems.variant.color",
from: "themeValues",
localField: "shipmentItems.variant.themeValue",
foreignField: "_id",
as: "shipmentItems.variant.color",
as: "shipmentItems.variant.themeValue",
},
},
{
$unwind: {
path: "$shipmentItems.variant.color",
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "sizes",
localField: "shipmentItems.variant.size",
foreignField: "_id",
as: "shipmentItems.variant.size",
},
},
{
$unwind: {
path: "$shipmentItems.variant.size",
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "meterages",
localField: "shipmentItems.variant.meterage",
foreignField: "_id",
as: "shipmentItems.variant.meterage",
},
},
{
$unwind: {
path: "$shipmentItems.variant.meterage",
path: "$shipmentItems.variant.themeValue",
preserveNullAndEmptyArrays: true,
},
},
@@ -1730,43 +1646,15 @@ class OrderItemRepo extends BaseRepository<IOrderItem> {
},
{
$lookup: {
from: "colors",
localField: "shipmentItems.variant.color",
from: "themeValues",
localField: "shipmentItems.variant.themeValue",
foreignField: "_id",
as: "shipmentItems.variant.color",
as: "shipmentItems.variant.themeValue",
},
},
{
$unwind: {
path: "$shipmentItems.variant.color",
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "sizes",
localField: "shipmentItems.variant.size",
foreignField: "_id",
as: "shipmentItems.variant.size",
},
},
{
$unwind: {
path: "$shipmentItems.variant.size",
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "meterages",
localField: "shipmentItems.variant.meterage",
foreignField: "_id",
as: "shipmentItems.variant.meterage",
},
},
{
$unwind: {
path: "$shipmentItems.variant.meterage",
path: "$shipmentItems.variant.themeValue",
preserveNullAndEmptyArrays: true,
},
},
+4 -24
View File
@@ -4,7 +4,7 @@ import { IsString } from "class-validator";
import { ApiProperty } from "../../../common/decorator/swggerDocs";
import { ProductStatus } from "../../../common/enums/product.enum";
import { BrandDTO } from "../../brand/DTO/brand.dto";
import { CategoryTreeDTO, ColorDTO, Size_MeterageDTO } from "../../category/DTO/category.dto";
import { CategoryTreeDTO } from "../../category/DTO/category.dto";
import { ShipmentMethodDTO } from "../../shipment/DTO/shipment.dto";
import { ShopDTO } from "../../shop/DTO/shop.dto";
import { WarrantyDTO } from "../../warranty/DTO/warranty.dto";
@@ -83,7 +83,7 @@ class SaleFormatDTO {
//#################################
class ThemeValueDTO {
export class ThemeValueDTO {
@Expose()
_id: string;
@@ -141,18 +141,6 @@ export class ProductDetailVariantDTO {
@Type(() => WarrantyDTO)
warranty: WarrantyDTO;
@Expose()
@Type(() => ColorDTO)
color?: ColorDTO;
@Expose()
@Type(() => Size_MeterageDTO)
size?: Size_MeterageDTO;
@Expose()
@Type(() => Size_MeterageDTO)
meterage?: Size_MeterageDTO;
@Expose()
@Type(() => ThemeValueDTO)
themeValue?: ThemeValueDTO;
@@ -302,16 +290,8 @@ export class ProductVariantDTO {
saleFormat: SaleFormatDTO;
@Expose()
@Type(() => ColorDTO)
color?: ColorDTO;
@Expose()
@Type(() => Size_MeterageDTO)
size?: Size_MeterageDTO;
@Expose()
@Type(() => Size_MeterageDTO)
meterage?: Size_MeterageDTO;
@Type(() => ThemeValueDTO)
themeValue?: ThemeValueDTO;
public static transformProduct(data: IProductVariant): ProductVariantDTO {
const productVariantDTO = plainToInstance(ProductVariantDTO, data, {
@@ -117,43 +117,15 @@ export class IncredibleOffersRepo extends BaseRepository<IncredibleOffers> {
},
{
$lookup: {
from: "colors",
localField: "product.default_variant.color",
from: "themeValues",
localField: "product.default_variant.themeValue",
foreignField: "_id",
as: "product.default_variant.color",
as: "product.default_variant.themeValue",
},
},
{
$unwind: {
path: "$product.default_variant.color",
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "sizes",
localField: "product.default_variant.size",
foreignField: "_id",
as: "product.default_variant.size",
},
},
{
$unwind: {
path: "$product.default_variant.size",
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "meterages",
localField: "product.default_variant.meterage",
foreignField: "_id",
as: "product.default_variant.meterage",
},
},
{
$unwind: {
path: "$product.variant.meterage",
path: "$product.default_variant.themeValue",
preserveNullAndEmptyArrays: true,
},
},
@@ -251,43 +223,15 @@ export class IncredibleOffersRepo extends BaseRepository<IncredibleOffers> {
},
{
$lookup: {
from: "colors",
localField: "variant.color",
from: "themeValues",
localField: "variant.themeValue",
foreignField: "_id",
as: "variant.color",
as: "variant.themeValue",
},
},
{
$unwind: {
path: "$variant.color",
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "sizes",
localField: "variant.size",
foreignField: "_id",
as: "variant.size",
},
},
{
$unwind: {
path: "$variant.size",
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "meterages",
localField: "variant.meterage",
foreignField: "_id",
as: "variant.meterage",
},
},
{
$unwind: {
path: "$variant.meterage",
path: "$variant.themeValue",
preserveNullAndEmptyArrays: true,
},
},
+25 -160
View File
@@ -1747,48 +1747,22 @@ export class ProductRepository extends BaseRepository<IProduct> {
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "colors",
localField: "variants.color",
from: "themeValues",
localField: "variants.themeValue",
foreignField: "_id",
as: "variants.color",
as: "variants.themeValue",
},
},
{
$unwind: {
path: "$variants.color",
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "sizes",
localField: "variants.size",
foreignField: "_id",
as: "variants.size",
},
},
{
$unwind: {
path: "$variants.size",
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "meterages",
localField: "variants.meterage",
foreignField: "_id",
as: "variants.meterage",
},
},
{
$unwind: {
path: "$variants.meterage",
path: "$variants.themeValue",
preserveNullAndEmptyArrays: true,
},
},
{
$group: {
_id: "$_id",
@@ -2037,43 +2011,15 @@ export class ProductRepository extends BaseRepository<IProduct> {
},
{
$lookup: {
from: "colors",
localField: "variants.color",
from: "themeValues",
localField: "variants.themeValue",
foreignField: "_id",
as: "variants.color",
as: "variants.themeValue",
},
},
{
$unwind: {
path: "$variants.color",
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "sizes",
localField: "variants.size",
foreignField: "_id",
as: "variants.size",
},
},
{
$unwind: {
path: "$variants.size",
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "meterages",
localField: "variants.meterage",
foreignField: "_id",
as: "variants.meterage",
},
},
{
$unwind: {
path: "$variants.meterage",
path: "$variants.themeValue",
preserveNullAndEmptyArrays: true,
},
},
@@ -2311,45 +2257,18 @@ export class ProductRepository extends BaseRepository<IProduct> {
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "colors",
localField: "variants.color",
from: "themeValues",
localField: "variants.themeValue",
foreignField: "_id",
as: "variants.color",
as: "variants.themeValue",
},
},
{
$unwind: {
path: "$variants.color",
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "sizes",
localField: "variants.size",
foreignField: "_id",
as: "variants.size",
},
},
{
$unwind: {
path: "$variants.size",
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "meterages",
localField: "variants.meterage",
foreignField: "_id",
as: "variants.meterage",
},
},
{
$unwind: {
path: "$variants.meterage",
path: "$variants.themeValue",
preserveNullAndEmptyArrays: true,
},
},
@@ -2486,45 +2405,18 @@ export class ProductRepository extends BaseRepository<IProduct> {
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "colors",
localField: "variants.color",
from: "themeValues",
localField: "variants.themeValue",
foreignField: "_id",
as: "variants.color",
as: "variants.themeValue",
},
},
{
$unwind: {
path: "$variants.color",
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "sizes",
localField: "variants.size",
foreignField: "_id",
as: "variants.size",
},
},
{
$unwind: {
path: "$variants.size",
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "meterages",
localField: "variants.meterage",
foreignField: "_id",
as: "variants.meterage",
},
},
{
$unwind: {
path: "$variants.meterage",
path: "$variants.themeValue",
preserveNullAndEmptyArrays: true,
},
},
@@ -2647,45 +2539,18 @@ export class ProductRepository extends BaseRepository<IProduct> {
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "colors",
localField: "variants.color",
from: "themeValues",
localField: "variants.themeValue",
foreignField: "_id",
as: "variants.color",
as: "variants.themeValue",
},
},
{
$unwind: {
path: "$variants.color",
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "sizes",
localField: "variants.size",
foreignField: "_id",
as: "variants.size",
},
},
{
$unwind: {
path: "$variants.size",
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "meterages",
localField: "variants.meterage",
foreignField: "_id",
as: "variants.meterage",
},
},
{
$unwind: {
path: "$variants.meterage",
path: "$variants.themeValue",
preserveNullAndEmptyArrays: true,
},
},
@@ -86,28 +86,13 @@ export class ProductVariantRepository extends BaseRepository<IProductVariant> {
{
$unwind: "$category",
},
{
$lookup: {
from: "colors",
localField: "color",
from: "themeValues",
localField: "themeValue",
foreignField: "_id",
as: "color",
},
},
{
$lookup: {
from: "sizes",
localField: "size",
foreignField: "_id",
as: "size",
},
},
{
$lookup: {
from: "meterages",
localField: "meterage",
foreignField: "_id",
as: "meterage",
as: "themeValue",
},
},
{
@@ -120,22 +105,11 @@ export class ProductVariantRepository extends BaseRepository<IProductVariant> {
},
{
$unwind: {
path: "$color",
preserveNullAndEmptyArrays: true,
},
},
{
$unwind: {
path: "$size",
preserveNullAndEmptyArrays: true,
},
},
{
$unwind: {
path: "$meterage",
path: "$themeValue",
preserveNullAndEmptyArrays: true,
},
},
{
$addFields: {
product_id: "$product._id",
@@ -259,28 +233,13 @@ export class ProductVariantRepository extends BaseRepository<IProductVariant> {
{
$unwind: "$category",
},
{
$lookup: {
from: "colors",
localField: "color",
from: "themeValues",
localField: "themeValue",
foreignField: "_id",
as: "color",
},
},
{
$lookup: {
from: "sizes",
localField: "size",
foreignField: "_id",
as: "size",
},
},
{
$lookup: {
from: "meterages",
localField: "meterage",
foreignField: "_id",
as: "meterage",
as: "themeValue",
},
},
{
@@ -293,22 +252,11 @@ export class ProductVariantRepository extends BaseRepository<IProductVariant> {
},
{
$unwind: {
path: "$color",
preserveNullAndEmptyArrays: true,
},
},
{
$unwind: {
path: "$size",
preserveNullAndEmptyArrays: true,
},
},
{
$unwind: {
path: "$meterage",
path: "$themeValue",
preserveNullAndEmptyArrays: true,
},
},
{
$addFields: {
product_id: "$product._id",
@@ -400,28 +348,13 @@ export class ProductVariantRepository extends BaseRepository<IProductVariant> {
{
$unwind: "$category",
},
{
$lookup: {
from: "colors",
localField: "color",
from: "themeValues",
localField: "themeValue",
foreignField: "_id",
as: "color",
},
},
{
$lookup: {
from: "sizes",
localField: "size",
foreignField: "_id",
as: "size",
},
},
{
$lookup: {
from: "meterages",
localField: "meterage",
foreignField: "_id",
as: "meterage",
as: "themeValue",
},
},
{
@@ -434,22 +367,11 @@ export class ProductVariantRepository extends BaseRepository<IProductVariant> {
},
{
$unwind: {
path: "$color",
preserveNullAndEmptyArrays: true,
},
},
{
$unwind: {
path: "$size",
preserveNullAndEmptyArrays: true,
},
},
{
$unwind: {
path: "$meterage",
path: "$themeValue",
preserveNullAndEmptyArrays: true,
},
},
{
$addFields: {
product_id: "$product._id",