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;
@ManyToOne(type => Asset, { onDelete: 'SET NULL' })
featuredAsset: Asset;
@OneToMany(type => ProductVariantAsset, productVariantAsset => productVariantAsset.productVariant, {
onDelete: 'SET NULL',
})
assets: ProductVariantAsset[];
@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;
@EntityId({ nullable: true })
productId: ID;
@Column({ default: 0 })
stockOnHand: number;
@Column({ default: 0 })
stockAllocated: number;
@Column({ default: 0 })
outOfStockThreshold: number;
@Column({ default: true })
useGlobalOutOfStockThreshold: boolean;
@Column({ type: 'varchar', default: GlobalFlag.INHERIT })
trackInventory: GlobalFlag;
@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[];
@ManyToMany(type => Channel)
@JoinTable()
channels: Channel[];
}
Extends
Implements
- Translatable
- HasCustomFields
- SoftDeletable
- ChannelAware
Members
constructor
(input?: DeepPartial<ProductVariant>) => ProductVariant
deletedAt
Date | null
name
LocaleString
enabled
boolean
sku
string
listPrice
number
listPriceIncludesTax
boolean
currencyCode
CurrencyCode
price
number
priceWithTax
number
taxRateApplied
TaxRate
featuredAsset
Asset
assets
ProductVariantAsset[]
taxCategory
TaxCategory
productVariantPrices
ProductVariantPrice[]
translations
Array<Translation<ProductVariant>>
product
Product
productId
ID
stockOnHand
number
stockAllocated
number
outOfStockThreshold
number
useGlobalOutOfStockThreshold
boolean
outOfStockThreshold
value will be taken from the GlobalSettings and the
value set on this ProductVariant will be ignored.
trackInventory
GlobalFlag
stockMovements
StockMovement[]
options
ProductOption[]
facetValues
FacetValue[]
customFields
CustomProductVariantFields
collections
Collection[]
channels
Channel[]