From e7f0fe2c091c472d8a0723bc5122260b84b1418c Mon Sep 17 00:00:00 2001 From: HausTechTeam <157805863+HausTechTeam@users.noreply.github.com> Date: Tue, 30 Jan 2024 13:32:07 +0100 Subject: [PATCH] feat(core): A support for custom fields on ProductVariantPrice (#2654) --- packages/core/src/config/custom-field/custom-field-types.ts | 1 + packages/core/src/config/default-config.ts | 1 + packages/core/src/entity/custom-entity-fields.ts | 1 + .../entity/product-variant/product-variant-price.entity.ts | 6 +++++- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/core/src/config/custom-field/custom-field-types.ts b/packages/core/src/config/custom-field/custom-field-types.ts index 0f52100df8..08c01fe338 100644 --- a/packages/core/src/config/custom-field/custom-field-types.ts +++ b/packages/core/src/config/custom-field/custom-field-types.ts @@ -165,6 +165,7 @@ export type CustomFields = { ProductOption?: CustomFieldConfig[]; ProductOptionGroup?: CustomFieldConfig[]; ProductVariant?: CustomFieldConfig[]; + ProductVariantPrice?: CustomFieldConfig[]; Promotion?: CustomFieldConfig[]; Region?: CustomFieldConfig[]; Seller?: CustomFieldConfig[]; diff --git a/packages/core/src/config/default-config.ts b/packages/core/src/config/default-config.ts index 30bf22c075..49a7b08225 100644 --- a/packages/core/src/config/default-config.ts +++ b/packages/core/src/config/default-config.ts @@ -198,6 +198,7 @@ export const defaultConfig: RuntimeVendureConfig = { ProductOption: [], ProductOptionGroup: [], ProductVariant: [], + ProductVariantPrice: [], Promotion: [], Region: [], Seller: [], diff --git a/packages/core/src/entity/custom-entity-fields.ts b/packages/core/src/entity/custom-entity-fields.ts index 15bebf6e91..298368199e 100644 --- a/packages/core/src/entity/custom-entity-fields.ts +++ b/packages/core/src/entity/custom-entity-fields.ts @@ -24,6 +24,7 @@ export class CustomProductOptionGroupFields {} export class CustomProductOptionGroupFieldsTranslation {} export class CustomProductVariantFields {} export class CustomProductVariantFieldsTranslation {} +export class CustomProductVariantPriceFields {} export class CustomPromotionFields {} export class CustomPromotionFieldsTranslation {} export class CustomRegionFields {} diff --git a/packages/core/src/entity/product-variant/product-variant-price.entity.ts b/packages/core/src/entity/product-variant/product-variant-price.entity.ts index bef6bc19c4..599585267b 100644 --- a/packages/core/src/entity/product-variant/product-variant-price.entity.ts +++ b/packages/core/src/entity/product-variant/product-variant-price.entity.ts @@ -2,6 +2,7 @@ import { CurrencyCode } from '@vendure/common/lib/generated-types'; import { DeepPartial, ID } from '@vendure/common/lib/shared-types'; import { Column, Entity, Index, ManyToOne } from 'typeorm'; +import { CustomProductVariantPriceFields, HasCustomFields } from '../..'; import { VendureEntity } from '../base/base.entity'; import { EntityId } from '../entity-id.decorator'; import { Money } from '../money.decorator'; @@ -16,7 +17,7 @@ import { ProductVariant } from './product-variant.entity'; * @docsCategory entities */ @Entity() -export class ProductVariantPrice extends VendureEntity { +export class ProductVariantPrice extends VendureEntity implements HasCustomFields { constructor(input?: DeepPartial) { super(input); } @@ -31,4 +32,7 @@ export class ProductVariantPrice extends VendureEntity { @Index() @ManyToOne(type => ProductVariant, variant => variant.productVariantPrices, { onDelete: 'CASCADE' }) variant: ProductVariant; + + @Column(type => CustomProductVariantPriceFields) + customFields: CustomProductVariantPriceFields; }