ProductVariant
ProductVariant
A ProductVariant represents a single stock keeping unit (SKU) in the store's inventory. Whereas a Product is a "container" of variants, the variant itself holds the data on price, tax category etc. When one adds items to their cart, they are adding ProductVariants, not Products.
Signature
class ProductVariant extends VendureEntity implements Translatable, HasCustomFields, SoftDeletable, ChannelAware {
constructor(input?: DeepPartial<ProductVariant>)
@Column({ type: Date, nullable: true })
deletedAt: Date | null;
name: LocaleString;
@Column({ default: true })
enabled: boolean;
@Column()
sku: string;
listPrice: number;
listPriceIncludesTax: boolean;
currencyCode: CurrencyCode;
price: number
priceWithTax: number
taxRateApplied: TaxRate;
@Index()
@ManyToOne(type => Asset, asset => asset.featuredInVariants, { onDelete: 'SET NULL' })
featuredAsset: Asset;
@OneToMany(type => ProductVariantAsset, productVariantAsset => productVariantAsset.productVariant, {
onDelete: 'SET NULL',
})
assets: ProductVariantAsset[];
@Index()
@ManyToOne(type => TaxCategory, taxCategory => taxCategory.productVariants)
taxCategory: TaxCategory;
@OneToMany(type => ProductVariantPrice, price => price.variant, { eager: true })
productVariantPrices: ProductVariantPrice[];
@OneToMany(type => ProductVariantTranslation, translation => translation.base, { eager: true })
translations: Array<Translation<ProductVariant>>;
@Index()
@ManyToOne(type => Product, product => product.variants)
product: Product;
@EntityId({ nullable: true })
productId: ID;
@Column({ default: 0 })
outOfStockThreshold: number;
@Column({ default: true })
useGlobalOutOfStockThreshold: boolean;
@Column({ type: 'varchar', default: GlobalFlag.INHERIT })
trackInventory: GlobalFlag;
@OneToMany(type => StockLevel, stockLevel => stockLevel.productVariant)
stockLevels: StockLevel[];
@OneToMany(type => StockMovement, stockMovement => stockMovement.productVariant)
stockMovements: StockMovement[];
@ManyToMany(type => ProductOption, productOption => productOption.productVariants)
@JoinTable()
options: ProductOption[];
@ManyToMany(type => FacetValue, facetValue => facetValue.productVariants)
@JoinTable()
facetValues: FacetValue[];
@Column(type => CustomProductVariantFields)
customFields: CustomProductVariantFields;
@ManyToMany(type => Collection, collection => collection.productVariants)
collections: Collection[];
@ManyToMany(type => Channel, channel => channel.productVariants)
@JoinTable()
channels: Channel[];
@OneToMany(type => OrderLine, orderLine => orderLine.productVariant)
lines: OrderLine[];
}
-
Extends:
VendureEntity -
Implements:
Translatable,HasCustomFields,SoftDeletable,ChannelAware
constructor
method
(input?: DeepPartial<ProductVariant>) => ProductVariantdeletedAt
property
Date | nullname
property
LocaleStringenabled
property
booleansku
property
stringlistPrice
property
numberlistPriceIncludesTax
property
booleancurrencyCode
property
price
property
numberpriceWithTax
property
numbertaxRateApplied
property
featuredAsset
property
assets
property
ProductVariantAsset[]taxCategory
property
productVariantPrices
property
translations
property
Array<Translation<ProductVariant>>product
property
productId
property
outOfStockThreshold
property
numberSpecifies the value of stockOnHand at which the ProductVariant is considered out of stock.
useGlobalOutOfStockThreshold
property
booleanWhen true, the outOfStockThreshold value will be taken from the GlobalSettings and the
value set on this ProductVariant will be ignored.
trackInventory
property
GlobalFlagstockLevels
property
stockMovements
property
options
property
facetValues
property
customFields
property
CustomProductVariantFieldscollections
property
channels
property
Channel[]lines
property