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 {
  constructor(input?: DeepPartial<ProductVariant>)
  name: LocaleString;
  @Column({ default: true })
    enabled: boolean;
  @Column()
    sku: string;
  @Column({
        name: 'lastPriceValue',
        comment: 'Not used - actual price is stored in product_variant_price table',
    })
    price: number;
  currencyCode: CurrencyCode;
  priceIncludesTax: boolean;
  priceWithTax: number;
  taxRateApplied: TaxRate;
  @ManyToOne(type => Asset)
    featuredAsset: Asset;
  @ManyToMany(type => Asset)
    @JoinTable()
    assets: Asset[];
  @ManyToOne(type => TaxCategory)
    taxCategory: TaxCategory;
  @OneToMany(type => ProductVariantPrice, price => price.variant, { eager: true })
    productVariantPrices: ProductVariantPrice[];
  @OneToMany(type => ProductVariantTranslation, translation => translation.base, { eager: true })
    translations: Array<Translation<ProductVariant>>;
  @ManyToOne(type => Product, product => product.variants)
    product: Product;
  @Column({ nullable: true })
    productId: number;
  @Column({ default: 0 })
    stockOnHand: number;
  @Column()
    trackInventory: boolean;
  @OneToMany(type => StockMovement, stockMovement => stockMovement.productVariant)
    stockMovements: StockMovement[];
  @ManyToMany(type => ProductOption)
    @JoinTable()
    options: ProductOption[];
  @ManyToMany(type => FacetValue)
    @JoinTable()
    facetValues: FacetValue[];
  @Column(type => CustomProductVariantFields)
    customFields: CustomProductVariantFields;
  @ManyToMany(type => Collection, collection => collection.productVariants)
    collections: Collection[];
}

Members

constructor

method
type:
(input?: DeepPartial<ProductVariant>) => ProductVariant

name

property
type:
LocaleString

enabled

property
type:
boolean

sku

property
type:
string

price

property
type:
number

currencyCode

property
type:
CurrencyCode

priceIncludesTax

property
type:
boolean

priceWithTax

property
type:
number

taxRateApplied

property
type:
TaxRate

featuredAsset

property
type:
Asset

assets

property
type:
Asset[]

taxCategory

property
type:
TaxCategory

productVariantPrices

property
type:
ProductVariantPrice[]

translations

property
type:
Array<Translation<ProductVariant>>

product

property
type:
Product

productId

property
type:
number

stockOnHand

property
type:
number

trackInventory

property
type:
boolean

stockMovements

property
type:
StockMovement[]

options

property
type:
ProductOption[]

facetValues

property
type:
FacetValue[]

customFields

property
type:
CustomProductVariantFields

collections

property
type:
Collection[]