Skip to main content
Skip to main content

ProductCollectionService

Provides layer to manipulate product collections.

constructor

Parameters

__namedParametersInjectedDependenciesRequired

Properties

manager_EntityManagerRequired
transactionManager_undefined | EntityManagerRequired
__container__anyRequired
eventBus_EventBusServiceRequired
productCollectionRepository_Repository<ProductCollection> & objectRequired
productRepository_Repository<Product> & objectRequired
EventsobjectRequired
Events.CREATEDstringRequired

Default: "product-collection.created"

Events.UPDATEDstringRequired

Default: "product-collection.updated"

Events.DELETEDstringRequired

Default: "product-collection.deleted"

Events.PRODUCTS_ADDEDstringRequired

Default: "product-collection.products_added"

Events.PRODUCTS_REMOVEDstringRequired

Default: "product-collection.products_removed"

__configModule__Record<string, unknown>
__moduleDeclaration__Record<string, unknown>

Accessors

activeManager_

Returns

EntityManagerEntityManagerRequired

Methods

withTransaction

Parameters

transactionManagerEntityManager

Returns

thisthisRequired

shouldRetryTransaction_

Parameters

errRecord<string, unknown> | objectRequired

Returns

booleanbooleanRequired

atomicPhase_

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.

Type Parameters

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

PromisePromise<TResult>Required
the result of the transactional work

retrieve

Retrieves a product collection by id.

Parameters

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

Default: {}

Returns

PromisePromise<ProductCollection>Required
the collection.

retrieveByHandle

Retrieves a product collection by id.

Parameters

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

Default: {}

Returns

PromisePromise<ProductCollection>Required
the collection.

create

Creates a product collection

Parameters

collectionCreateProductCollectionRequired
the collection to create

Returns

PromisePromise<ProductCollection>Required
created collection

update

Updates a product collection

Parameters

collectionIdstringRequired
id of collection to update
updateUpdateProductCollectionRequired
update object

Returns

PromisePromise<ProductCollection>Required
update collection

delete

Deletes a product collection idempotently

Parameters

collectionIdstringRequired
id of collection to delete

Returns

PromisePromise<void>Required
empty promise

addProducts

Parameters

collectionIdstringRequired
productIdsstring[]Required

Returns

PromisePromise<ProductCollection>Required

removeProducts

Parameters

collectionIdstringRequired
productIdsstring[]Required

Returns

PromisePromise<void>Required

list

Lists product collections

Parameters

selectorSelector<ProductCollection> & objectRequired
the query object for find

Default: {}

configobjectRequired
the config to be used for find
config.skipnumberRequired

Default: 0

config.takenumberRequired

Default: 20

Returns

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

listAndCount

Lists product collections and add count.

Parameters

selectorListAndCountSelectorRequired
the query object for find

Default: {}

the config to be used for find

Returns

PromisePromise<[ProductCollection[], number]>Required
the result of the find operation
Was this section helpful?