ProductCollectionService
Provides layer to manipulate product collections.
Constructors
constructor
**new ProductCollectionService**(«destructured»)
Parameters
Properties
__configModule__
Record<string, unknown>__container__
anyRequired__moduleDeclaration__
Record<string, unknown>manager_
EntityManagerRequiredproductCollectionRepository_
Repository<ProductCollection> & { findAndCountByDiscountConditionId: Method findAndCountByDiscountConditionId }RequiredproductRepository_
Repository<Product> & { _applyCategoriesQuery: Method _applyCategoriesQuery ; _findWithRelations: Method _findWithRelations ; bulkAddToCollection: Method bulkAddToCollection ; bulkRemoveFromCollection: Method bulkRemoveFromCollection ; findOneWithRelations: Method findOneWithRelations ; findWithRelations: Method findWithRelations ; findWithRelationsAndCount: Method findWithRelationsAndCount ; getCategoryIdsFromInput: Method getCategoryIdsFromInput ; getCategoryIdsRecursively: Method getCategoryIdsRecursively ; getFreeTextSearchResultsAndCount: Method getFreeTextSearchResultsAndCount ; isProductInSalesChannels: Method isProductInSalesChannels ; queryProducts: Method queryProducts ; queryProductsWithIds: Method queryProductsWithIds }RequiredtransactionManager_
undefined | EntityManagerRequiredEvents
objectRequiredEvents.CREATED
stringRequiredDefault: "product-collection.created"
Events.DELETED
stringRequiredDefault: "product-collection.deleted"
Events.PRODUCTS_ADDED
stringRequiredDefault: "product-collection.products_added"
Events.PRODUCTS_REMOVED
stringRequiredDefault: "product-collection.products_removed"
Events.UPDATED
stringRequiredDefault: "product-collection.updated"
Accessors
activeManager_
Protected get**activeManager_**(): EntityManager
Returns
EntityManager
EntityManager
EntityManagerRequiredMethods
addProducts
**addProducts**(collectionId, productIds): Promise<[ProductCollection](/references/services/classes/ProductCollection)>
Parameters
collectionId
stringRequiredproductIds
string[]RequiredReturns
Promise<ProductCollection>
atomicPhase_
Protected **atomicPhase_**<TypeParameter TResult, TypeParameter TError>(work, isolationOrErrorHandler?, maybeErrorHandlerOrDontFail?): Promise<TResult>
Wraps some work within a transactional block. If the service already has a transaction manager attached this will be reused, otherwise a new transaction manager is created.
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Returns
Promise<TResult>
Promise
Promise<TResult>Requiredcreate
**create**(collection): Promise<[ProductCollection](/references/services/classes/ProductCollection)>
Creates a product collection
Parameters
Returns
Promise<ProductCollection>
delete
**delete**(collectionId): Promise<void>
Deletes a product collection idempotently
Parameters
collectionId
stringRequiredReturns
Promise<void>
Promise
Promise<void>Requiredlist
**list**(selector?, config?): Promise<[ProductCollection](/references/services/classes/ProductCollection)[]>
Lists product collections
Parameters
Default: {}
config
objectRequiredconfig.skip
numberRequiredDefault: 0
config.take
numberRequiredDefault: 20
Returns
Promise<ProductCollection[]>
listAndCount
**listAndCount**(selector?, config?): Promise<[[ProductCollection](/references/services/classes/ProductCollection)[], number]>
Lists product collections and add count.
Parameters
Default: {}
Returns
Promise<[ProductCollection[], number]>
removeProducts
**removeProducts**(collectionId, productIds): Promise<void>
Parameters
collectionId
stringRequiredproductIds
string[]RequiredReturns
Promise<void>
Promise
Promise<void>Requiredretrieve
**retrieve**(collectionId, config?): Promise<[ProductCollection](/references/services/classes/ProductCollection)>
Retrieves a product collection by id.
Parameters
collectionId
stringRequiredDefault: {}
Returns
Promise<ProductCollection>
retrieveByHandle
**retrieveByHandle**(collectionHandle, config?): Promise<[ProductCollection](/references/services/classes/ProductCollection)>
Retrieves a product collection by id.
Parameters
collectionHandle
stringRequiredDefault: {}
Returns
Promise<ProductCollection>
shouldRetryTransaction_
Protected **shouldRetryTransaction_**(err): boolean
Parameters
err
Record<string, unknown> | { code: string }RequiredReturns
boolean
boolean
booleanupdate
**update**(collectionId, update): Promise<[ProductCollection](/references/services/classes/ProductCollection)>
Updates a product collection
Parameters
collectionId
stringRequiredReturns
Promise<ProductCollection>
withTransaction
**withTransaction**(transactionManager?): [ProductCollectionService](/references/services/classes/ProductCollectionService)
Parameters
transactionManager
EntityManager