title | isDefaultIndex | generated |
---|---|---|
ProductVariant |
false |
true |
import MemberInfo from '@site/src/components/MemberInfo'; import GenerationInfo from '@site/src/components/GenerationInfo'; import MemberDescription from '@site/src/components/MemberDescription';
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.
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
<MemberInfo kind="method" type={(input?: DeepPartial<<a href='/reference/typescript-api/entities/product-variant#productvariant'>ProductVariant</a>>) => ProductVariant
} />
<MemberInfo kind="property" type={Date | null
} />
<MemberInfo kind="property" type={LocaleString
} />
<MemberInfo kind="property" type={boolean
} />
<MemberInfo kind="property" type={string
} />
<MemberInfo kind="property" type={number
} />
<MemberInfo kind="property" type={boolean
} />
<MemberInfo kind="property" type={<a href='/reference/typescript-api/common/currency-code#currencycode'>CurrencyCode</a>
} />
<MemberInfo kind="property" type={number
} />
<MemberInfo kind="property" type={number
} />
<MemberInfo kind="property" type={<a href='/reference/typescript-api/entities/tax-rate#taxrate'>TaxRate</a>
} />
<MemberInfo kind="property" type={<a href='/reference/typescript-api/entities/asset#asset'>Asset</a>
} />
<MemberInfo kind="property" type={ProductVariantAsset[]
} />
<MemberInfo kind="property" type={<a href='/reference/typescript-api/entities/tax-category#taxcategory'>TaxCategory</a>
} />
<MemberInfo kind="property" type={<a href='/reference/typescript-api/entities/product-variant-price#productvariantprice'>ProductVariantPrice</a>[]
} />
<MemberInfo kind="property" type={Array<Translation<<a href='/reference/typescript-api/entities/product-variant#productvariant'>ProductVariant</a>>>
} />
<MemberInfo kind="property" type={<a href='/reference/typescript-api/entities/product#product'>Product</a>
} />
<MemberInfo kind="property" type={<a href='/reference/typescript-api/common/id#id'>ID</a>
} />
<MemberInfo kind="property" type={number
} />
Specifies the value of stockOnHand at which the ProductVariant is considered out of stock.
<MemberInfo kind="property" type={boolean
} />
When true, the outOfStockThreshold
value will be taken from the GlobalSettings and the
value set on this ProductVariant will be ignored.
<MemberInfo kind="property" type={GlobalFlag
} />
<MemberInfo kind="property" type={<a href='/reference/typescript-api/entities/stock-level#stocklevel'>StockLevel</a>[]
} />
<MemberInfo kind="property" type={<a href='/reference/typescript-api/entities/stock-movement#stockmovement'>StockMovement</a>[]
} />
<MemberInfo kind="property" type={<a href='/reference/typescript-api/entities/product-option#productoption'>ProductOption</a>[]
} />
<MemberInfo kind="property" type={<a href='/reference/typescript-api/entities/facet-value#facetvalue'>FacetValue</a>[]
} />
<MemberInfo kind="property" type={CustomProductVariantFields
} />
<MemberInfo kind="property" type={<a href='/reference/typescript-api/entities/collection#collection'>Collection</a>[]
} />
<MemberInfo kind="property" type={<a href='/reference/typescript-api/entities/channel#channel'>Channel</a>[]
} />
<MemberInfo kind="property" type={<a href='/reference/typescript-api/entities/order-line#orderline'>OrderLine</a>[]
} />