Skip to main content
Skip to main content

ProductCollectionService

internal.internal.ProductCollectionService

Provides layer to manipulate product collections.

Properties

__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
eventBus_EventBusServiceRequired
manager_EntityManagerRequired
productCollectionRepository_Repository<ProductCollection> & { findAndCountByDiscountConditionId: Method findAndCountByDiscountConditionId }Required
productRepository_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 }Required
transactionManager_undefined | EntityManagerRequired
EventsobjectRequired
Events.CREATEDstringRequired
Events.DELETEDstringRequired
Events.PRODUCTS_ADDEDstringRequired
Events.PRODUCTS_REMOVEDstringRequired
Events.UPDATEDstringRequired

Accessors

activeManager_

Protected get activeManager_(): EntityManager

Returns

EntityManager

EntityManagerEntityManagerRequired

Inherited from

TransactionBaseService.activeManager_

Methods

addProducts

addProducts(collectionId, productIds): Promise<ProductCollection>

Parameters

collectionIdstringRequired
productIdsstring[]Required

Returns

Promise<ProductCollection>

PromisePromise<ProductCollection>Required

atomicPhase_

Protected atomicPhase_<TResult, 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.

TResultobjectRequired
TErrorobjectRequired

Parameters

work(transactionManager: EntityManager) => Promise<TResult>Required
the transactional work to be done
isolationOrErrorHandlerIsolationLevel | (error: TError) => Promise<void | TResult>
the isolation level to be used for the work.
maybeErrorHandlerOrDontFail(error: TError) => Promise<void | TResult>
Potential error handler

Returns

Promise<TResult>

PromisePromise<TResult>Required
the result of the transactional work

Inherited from

TransactionBaseService.atomicPhase_


create

create(collection): Promise<ProductCollection>

Creates a product collection

Parameters

collectionCreateProductCollectionRequired
the collection to create

Returns

Promise<ProductCollection>

PromisePromise<ProductCollection>Required
created collection

delete

delete(collectionId): Promise<void>

Deletes a product collection idempotently

Parameters

collectionIdstringRequired
id of collection to delete

Returns

Promise<void>

PromisePromise<void>Required
empty promise

list

list(selector?, config?): Promise<ProductCollection[]>

Lists product collections

Parameters

selectorSelector<ProductCollection> & { discount_condition_id?: string ; q?: string }
the query object for find
configobject
the config to be used for find
config.skipnumberRequired
config.takenumberRequired

Returns

Promise<ProductCollection[]>

PromisePromise<ProductCollection[]>Required
the result of the find operation

listAndCount

listAndCount(selector?, config?): Promise<[ProductCollection[], number]>

Lists product collections and add count.

Parameters

the query object for find
the config to be used for find

Returns

Promise<[ProductCollection[], number]>

PromisePromise<[ProductCollection[], number]>Required
the result of the find operation

removeProducts

removeProducts(collectionId, productIds): Promise<void>

Parameters

collectionIdstringRequired
productIdsstring[]Required

Returns

Promise<void>

PromisePromise<void>Required

retrieve

retrieve(collectionId, config?): Promise<ProductCollection>

Retrieves a product collection by id.

Parameters

collectionIdstringRequired
the id of the collection to retrieve.
the config of the collection to retrieve.

Returns

Promise<ProductCollection>

PromisePromise<ProductCollection>Required
the collection.

retrieveByHandle

retrieveByHandle(collectionHandle, config?): Promise<ProductCollection>

Retrieves a product collection by id.

Parameters

collectionHandlestringRequired
the handle of the collection to retrieve.
query config for request

Returns

Promise<ProductCollection>

PromisePromise<ProductCollection>Required
the collection.

shouldRetryTransaction_

Protected shouldRetryTransaction_(err): boolean

Parameters

errRecord<string, unknown> | { code: string }Required

Returns

boolean

booleanboolean

Inherited from

TransactionBaseService.shouldRetryTransaction_


update

update(collectionId, update): Promise<ProductCollection>

Updates a product collection

Parameters

collectionIdstringRequired
id of collection to update
update object

Returns

Promise<ProductCollection>

PromisePromise<ProductCollection>Required
update collection

withTransaction

withTransaction(transactionManager?): ProductCollectionService

Parameters

transactionManagerEntityManager

Returns

ProductCollectionService

ProductCollectionServiceProductCollectionServiceRequired

Inherited from

TransactionBaseService.withTransaction

Was this section helpful?