Skip to content

Commit

Permalink
feat(core): A support for custom fields on ProductVariantPrice (#2654)
Browse files Browse the repository at this point in the history
  • Loading branch information
HausTechTeam authored Jan 30, 2024
1 parent ba8f604 commit e7f0fe2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export type CustomFields = {
ProductOption?: CustomFieldConfig[];
ProductOptionGroup?: CustomFieldConfig[];
ProductVariant?: CustomFieldConfig[];
ProductVariantPrice?: CustomFieldConfig[];
Promotion?: CustomFieldConfig[];
Region?: CustomFieldConfig[];
Seller?: CustomFieldConfig[];
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/config/default-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export const defaultConfig: RuntimeVendureConfig = {
ProductOption: [],
ProductOptionGroup: [],
ProductVariant: [],
ProductVariantPrice: [],
Promotion: [],
Region: [],
Seller: [],
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/entity/custom-entity-fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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<ProductVariantPrice>) {
super(input);
}
Expand All @@ -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;
}

0 comments on commit e7f0fe2

Please sign in to comment.