ProductVariant

ProductVariant

Documentation generated from product-variant.entity.ts on Feb 19 2019 at 16:20

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 {
  constructor(input: DeepPartial<ProductVariant>)
  name: LocaleString;
  @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;
  @ManyToMany(type => ProductOption)
    @JoinTable()
    options: ProductOption[];
  @ManyToMany(type => FacetValue)
    @JoinTable()
    facetValues: FacetValue[];
  @Column(type => CustomProductVariantFields)
    customFields: CustomProductVariantFields;
}

Members

constructor

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

name

property
type:
LocaleString

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

options

property
type:
ProductOption[]

facetValues

property
type:
FacetValue[]

customFields

property
type:
CustomProductVariantFields
alpha