ProductVariantService
ProductVariantService
Contains methods relating to ProductVariant entities.
Signature
class ProductVariantService {
constructor(connection: TransactionalConnection, configService: ConfigService, taxCategoryService: TaxCategoryService, facetValueService: FacetValueService, assetService: AssetService, translatableSaver: TranslatableSaver, eventBus: EventBus, listQueryBuilder: ListQueryBuilder, globalSettingsService: GlobalSettingsService, stockMovementService: StockMovementService, channelService: ChannelService, roleService: RoleService, customFieldRelationService: CustomFieldRelationService, requestCache: RequestContextCacheService, productPriceApplicator: ProductPriceApplicator, translator: TranslatorService)
async findAll(ctx: RequestContext, options?: ListQueryOptions<ProductVariant>) => Promise<PaginatedList<Translated<ProductVariant>>>;
findOne(ctx: RequestContext, productVariantId: ID, relations?: RelationPaths<ProductVariant>) => Promise<Translated<ProductVariant> | undefined>;
findByIds(ctx: RequestContext, ids: ID[]) => Promise<Array<Translated<ProductVariant>>>;
getVariantsByProductId(ctx: RequestContext, productId: ID, options: ListQueryOptions<ProductVariant> = {}, relations?: RelationPaths<ProductVariant>) => Promise<PaginatedList<Translated<ProductVariant>>>;
getVariantsByCollectionId(ctx: RequestContext, collectionId: ID, options: ListQueryOptions<ProductVariant>, relations: RelationPaths<ProductVariant> = []) => Promise<PaginatedList<Translated<ProductVariant>>>;
async getProductVariantChannels(ctx: RequestContext, productVariantId: ID) => Promise<Channel[]>;
async getVariantByOrderLineId(ctx: RequestContext, orderLineId: ID) => Promise<Translated<ProductVariant>>;
getOptionsForVariant(ctx: RequestContext, variantId: ID) => Promise<Array<Translated<ProductOption>>>;
getFacetValuesForVariant(ctx: RequestContext, variantId: ID) => Promise<Array<Translated<FacetValue>>>;
async getProductForVariant(ctx: RequestContext, variant: ProductVariant) => Promise<Translated<Product>>;
async getSaleableStockLevel(ctx: RequestContext, variant: ProductVariant) => Promise<number>;
async getDisplayStockLevel(ctx: RequestContext, variant: ProductVariant) => Promise<string>;
async getFulfillableStockLevel(ctx: RequestContext, variant: ProductVariant) => Promise<number>;
async create(ctx: RequestContext, input: CreateProductVariantInput[]) => Promise<Array<Translated<ProductVariant>>>;
async update(ctx: RequestContext, input: UpdateProductVariantInput[]) => Promise<Array<Translated<ProductVariant>>>;
async createOrUpdateProductVariantPrice(ctx: RequestContext, productVariantId: ID, price: number, channelId: ID) => Promise<ProductVariantPrice>;
async softDelete(ctx: RequestContext, id: ID | ID[]) => Promise<DeletionResponse>;
async hydratePriceFields(ctx: RequestContext, variant: ProductVariant, priceField: F) => Promise<ProductVariant[F]>;
async applyChannelPriceAndTax(variant: ProductVariant, ctx: RequestContext, order?: Order) => Promise<ProductVariant>;
async assignProductVariantsToChannel(ctx: RequestContext, input: AssignProductVariantsToChannelInput) => Promise<Array<Translated<ProductVariant>>>;
async removeProductVariantsFromChannel(ctx: RequestContext, input: RemoveProductVariantsFromChannelInput) => Promise<Array<Translated<ProductVariant>>>;
}
Members
constructor
(connection: TransactionalConnection, configService: ConfigService, taxCategoryService: TaxCategoryService, facetValueService: FacetValueService, assetService: AssetService, translatableSaver: TranslatableSaver, eventBus: EventBus, listQueryBuilder: ListQueryBuilder, globalSettingsService: GlobalSettingsService, stockMovementService: StockMovementService, channelService: ChannelService, roleService: RoleService, customFieldRelationService: CustomFieldRelationService, requestCache: RequestContextCacheService, productPriceApplicator: ProductPriceApplicator, translator: TranslatorService) => ProductVariantService
findAll
(ctx: RequestContext, options?: ListQueryOptions<ProductVariant>) => Promise<PaginatedList<Translated<ProductVariant>>>
findOne
(ctx: RequestContext, productVariantId: ID, relations?: RelationPaths<ProductVariant>) => Promise<Translated<ProductVariant> | undefined>
findByIds
(ctx: RequestContext, ids: ID[]) => Promise<Array<Translated<ProductVariant>>>
getVariantsByProductId
(ctx: RequestContext, productId: ID, options: ListQueryOptions<ProductVariant> = {}, relations?: RelationPaths<ProductVariant>) => Promise<PaginatedList<Translated<ProductVariant>>>
getVariantsByCollectionId
(ctx: RequestContext, collectionId: ID, options: ListQueryOptions<ProductVariant>, relations: RelationPaths<ProductVariant> = []) => Promise<PaginatedList<Translated<ProductVariant>>>
getProductVariantChannels
(ctx: RequestContext, productVariantId: ID) => Promise<Channel[]>
getVariantByOrderLineId
(ctx: RequestContext, orderLineId: ID) => Promise<Translated<ProductVariant>>
getOptionsForVariant
(ctx: RequestContext, variantId: ID) => Promise<Array<Translated<ProductOption>>>
getFacetValuesForVariant
(ctx: RequestContext, variantId: ID) => Promise<Array<Translated<FacetValue>>>
getProductForVariant
(ctx: RequestContext, variant: ProductVariant) => Promise<Translated<Product>>
ProductService.findOne()
method performs a large multi-table join with all the typical data needed for a “product detail”
page, this method returns only the Product itself.
getSaleableStockLevel
(ctx: RequestContext, variant: ProductVariant) => Promise<number>
stockOnHand
value,
as well as the local and global outOfStockThreshold
settings.
getDisplayStockLevel
(ctx: RequestContext, variant: ProductVariant) => Promise<string>
getFulfillableStockLevel
(ctx: RequestContext, variant: ProductVariant) => Promise<number>
create
(ctx: RequestContext, input: CreateProductVariantInput[]) => Promise<Array<Translated<ProductVariant>>>
update
(ctx: RequestContext, input: UpdateProductVariantInput[]) => Promise<Array<Translated<ProductVariant>>>
createOrUpdateProductVariantPrice
(ctx: RequestContext, productVariantId: ID, price: number, channelId: ID) => Promise<ProductVariantPrice>
softDelete
(ctx: RequestContext, id: ID | ID[]) => Promise<DeletionResponse>
hydratePriceFields
(ctx: RequestContext, variant: ProductVariant, priceField: F) => Promise<ProductVariant[F]>
This method is intended to be used by the ProductVariant GraphQL entity resolver to resolve the
price-related fields which need to be populated at run-time using the applyChannelPriceAndTax
method.
Is optimized to make as few DB calls as possible using caching based on the open request.
applyChannelPriceAndTax
(variant: ProductVariant, ctx: RequestContext, order?: Order) => Promise<ProductVariant>
price
field with the price for the specified channel.
assignProductVariantsToChannel
(ctx: RequestContext, input: AssignProductVariantsToChannelInput) => Promise<Array<Translated<ProductVariant>>>
removeProductVariantsFromChannel
(ctx: RequestContext, input: RemoveProductVariantsFromChannelInput) => Promise<Array<Translated<ProductVariant>>>