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;
@EntityId({ nullable: true })
featuredAssetId: ID;
@OneToMany(type => ProductVariantAsset, productVariantAsset => productVariantAsset.productVariant, {
onDelete: 'SET NULL',
})
assets: ProductVariantAsset[];
@Index()
@ManyToOne(type => TaxCategory, taxCategory => taxCategory.productVariants)
taxCategory: TaxCategory;
@EntityId({ nullable: true })
taxCategoryId: ID;
@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>) => ProductVariant
deletedAt
property
Date | null
name
property
LocaleString
enabled
property
boolean
sku
property
string
listPrice
property
number
listPriceIncludesTax
property
boolean
currencyCode
property
price
property
number
priceWithTax
property
number
taxRateApplied
property
featuredAsset
property
featuredAssetId
property
assets
property
ProductVariantAsset[]
taxCategory
property
taxCategoryId
property
productVariantPrices
property
translations
property
Array<Translation<ProductVariant>>
product
property
productId
property
outOfStockThreshold
property
number
Specifies the value of stockOnHand at which the ProductVariant is considered out of stock.
useGlobalOutOfStockThreshold
property
boolean
When true, the outOfStockThreshold
value will be taken from the GlobalSettings and the
value set on this ProductVariant will be ignored.
trackInventory
property
GlobalFlag
stockLevels
property
stockMovements
property
options
property
facetValues
property
customFields
property
CustomProductVariantFields
collections
property
channels
property
Channel[]
lines
property