Skip to main content

Class: ProductCollectionService

Provides layer to manipulate product collections.

Hierarchy

  • TransactionBaseServiceCopy to Clipboard

    ProductCollectionServiceCopy to Clipboard

Constructors

constructor

new ProductCollectionService(__namedParametersCopy to Clipboard)

Parameters

NameType
__namedParametersCopy to ClipboardInjectedDependenciesCopy to Clipboard

Overrides

TransactionBaseService.constructor

Defined in

packages/medusa/src/services/product-collection.ts:34

Properties

__configModule__

ProtectedCopy to Clipboard OptionalCopy to Clipboard ReadonlyCopy to Clipboard __configModule__: RecordCopy to Clipboard<stringCopy to Clipboard, unknownCopy to Clipboard>

Inherited from

TransactionBaseService.__configModule__

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:10


__container__

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard __container__: anyCopy to Clipboard

Inherited from

TransactionBaseService.__container__

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:9


__moduleDeclaration__

ProtectedCopy to Clipboard OptionalCopy to Clipboard ReadonlyCopy to Clipboard __moduleDeclaration__: RecordCopy to Clipboard<stringCopy to Clipboard, unknownCopy to Clipboard>

Inherited from

TransactionBaseService.__moduleDeclaration__

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:11


eventBus_

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard eventBus_: EventBusServiceCopy to Clipboard

Defined in

packages/medusa/src/services/product-collection.ts:29


manager_

ProtectedCopy to Clipboard manager_: EntityManagerCopy to Clipboard

Overrides

TransactionBaseService.manager_

Defined in

packages/medusa/src/services/product-collection.ts:26


productCollectionRepository_

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard productCollectionRepository_: typeof ProductCollectionRepositoryCopy to Clipboard

Defined in

packages/medusa/src/services/product-collection.ts:31


productRepository_

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard productRepository_: typeof ProductRepositoryCopy to Clipboard

Defined in

packages/medusa/src/services/product-collection.ts:32


transactionManager_

ProtectedCopy to Clipboard transactionManager_: undefinedCopy to Clipboard | EntityManagerCopy to Clipboard

Overrides

TransactionBaseService.transactionManager_

Defined in

packages/medusa/src/services/product-collection.ts:27

Methods

addProducts

addProducts(collectionIdCopy to Clipboard, productIdsCopy to Clipboard): PromiseCopy to Clipboard<ProductCollectionCopy to Clipboard>

Parameters

NameType
collectionIdCopy to ClipboardstringCopy to Clipboard
productIdsCopy to ClipboardstringCopy to Clipboard[]

Returns

PromiseCopy to Clipboard<ProductCollectionCopy to Clipboard>

Defined in

packages/medusa/src/services/product-collection.ts:181


atomicPhase_

ProtectedCopy to Clipboard atomicPhase_<TResultCopy to Clipboard, TErrorCopy to Clipboard>(workCopy to Clipboard, isolationOrErrorHandler?Copy to Clipboard, maybeErrorHandlerOrDontFail?Copy to Clipboard): PromiseCopy to Clipboard<TResultCopy to Clipboard>

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

Name
TResultCopy to Clipboard
TErrorCopy to Clipboard

Parameters

NameTypeDescription
workCopy to Clipboard(transactionManagerCopy to Clipboard: EntityManagerCopy to Clipboard) => PromiseCopy to Clipboard<TResultCopy to Clipboard>the transactional work to be done
isolationOrErrorHandler?Copy to ClipboardIsolationLevelCopy to Clipboard | (errorCopy to Clipboard: TErrorCopy to Clipboard) => PromiseCopy to Clipboard<voidCopy to Clipboard | TResultCopy to Clipboard>the isolation level to be used for the work.
maybeErrorHandlerOrDontFail?Copy to Clipboard(errorCopy to Clipboard: TErrorCopy to Clipboard) => PromiseCopy to Clipboard<voidCopy to Clipboard | TResultCopy to Clipboard>Potential error handler

Returns

PromiseCopy to Clipboard<TResultCopy to Clipboard>

the result of the transactional work

Inherited from

TransactionBaseService.atomicPhase_

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:50


create

create(collectionCopy to Clipboard): PromiseCopy to Clipboard<ProductCollectionCopy to Clipboard>

Creates a product collection

Parameters

NameTypeDescription
collectionCopy to ClipboardCreateProductCollectionCopy to Clipboardthe collection to create

Returns

PromiseCopy to Clipboard<ProductCollectionCopy to Clipboard>

created collection

Defined in

packages/medusa/src/services/product-collection.ts:114


delete

delete(collectionIdCopy to Clipboard): PromiseCopy to Clipboard<voidCopy to Clipboard>

Deletes a product collection idempotently

Parameters

NameTypeDescription
collectionIdCopy to ClipboardstringCopy to Clipboardid of collection to delete

Returns

PromiseCopy to Clipboard<voidCopy to Clipboard>

empty promise

Defined in

packages/medusa/src/services/product-collection.ts:163


list

list(selector?Copy to Clipboard, config?Copy to Clipboard): PromiseCopy to Clipboard<ProductCollectionCopy to Clipboard[]>

Lists product collections

Parameters

NameTypeDefault valueDescription
selectorCopy to ClipboardSelectorCopy to Clipboard<ProductCollectionCopy to Clipboard> & { discount_condition_id?Copy to Clipboard: stringCopy to Clipboard ; q?Copy to Clipboard: stringCopy to Clipboard }{}Copy to Clipboardthe query object for find
configCopy to ClipboardObjectCopy to ClipboardundefinedCopy to Clipboardthe config to be used for find
config.skipCopy to ClipboardnumberCopy to Clipboard0Copy to Clipboard-
config.takeCopy to ClipboardnumberCopy to Clipboard20Copy to Clipboard-

Returns

PromiseCopy to Clipboard<ProductCollectionCopy to Clipboard[]>

the result of the find operation

Defined in

packages/medusa/src/services/product-collection.ts:219


listAndCount

listAndCount(selector?Copy to Clipboard, config?Copy to Clipboard): PromiseCopy to Clipboard<[ProductCollectionCopy to Clipboard[], numberCopy to Clipboard]>

Lists product collections and add count.

Parameters

NameTypeDescription
selectorCopy to ClipboardSelectorCopy to Clipboard<ProductCollectionCopy to Clipboard> & { discount_condition_id?Copy to Clipboard: stringCopy to Clipboard ; q?Copy to Clipboard: stringCopy to Clipboard }the query object for find
configCopy to ClipboardFindConfigCopy to Clipboard<ProductCollectionCopy to Clipboard>the config to be used for find

Returns

PromiseCopy to Clipboard<[ProductCollectionCopy to Clipboard[], numberCopy to Clipboard]>

the result of the find operation

Defined in

packages/medusa/src/services/product-collection.ts:236


removeProducts

removeProducts(collectionIdCopy to Clipboard, productIdsCopy to Clipboard): PromiseCopy to Clipboard<voidCopy to Clipboard>

Parameters

NameType
collectionIdCopy to ClipboardstringCopy to Clipboard
productIdsCopy to ClipboardstringCopy to Clipboard[]

Returns

PromiseCopy to Clipboard<voidCopy to Clipboard>

Defined in

packages/medusa/src/services/product-collection.ts:198


retrieve

retrieve(collectionIdCopy to Clipboard, config?Copy to Clipboard): PromiseCopy to Clipboard<ProductCollectionCopy to Clipboard>

Retrieves a product collection by id.

Parameters

NameTypeDescription
collectionIdCopy to ClipboardstringCopy to Clipboardthe id of the collection to retrieve.
configCopy to ClipboardFindConfigCopy to Clipboard<ProductCollectionCopy to Clipboard>the config of the collection to retrieve.

Returns

PromiseCopy to Clipboard<ProductCollectionCopy to Clipboard>

the collection.

Defined in

packages/medusa/src/services/product-collection.ts:54


retrieveByHandle

retrieveByHandle(collectionHandleCopy to Clipboard, config?Copy to Clipboard): PromiseCopy to Clipboard<ProductCollectionCopy to Clipboard>

Retrieves a product collection by id.

Parameters

NameTypeDescription
collectionHandleCopy to ClipboardstringCopy to Clipboardthe handle of the collection to retrieve.
configCopy to ClipboardFindConfigCopy to Clipboard<ProductCollectionCopy to Clipboard>query config for request

Returns

PromiseCopy to Clipboard<ProductCollectionCopy to Clipboard>

the collection.

Defined in

packages/medusa/src/services/product-collection.ts:88


shouldRetryTransaction_

ProtectedCopy to Clipboard shouldRetryTransaction_(errCopy to Clipboard): booleanCopy to Clipboard

Parameters

NameType
errCopy to ClipboardRecordCopy to Clipboard<stringCopy to Clipboard, unknownCopy to Clipboard> | { codeCopy to Clipboard: stringCopy to Clipboard }

Returns

booleanCopy to Clipboard

Inherited from

TransactionBaseService.shouldRetryTransaction_

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:31


update

update(collectionIdCopy to Clipboard, updateCopy to Clipboard): PromiseCopy to Clipboard<ProductCollectionCopy to Clipboard>

Updates a product collection

Parameters

NameTypeDescription
collectionIdCopy to ClipboardstringCopy to Clipboardid of collection to update
updateCopy to ClipboardUpdateProductCollectionCopy to Clipboardupdate object

Returns

PromiseCopy to Clipboard<ProductCollectionCopy to Clipboard>

update collection

Defined in

packages/medusa/src/services/product-collection.ts:133


withTransaction

withTransaction(transactionManager?Copy to Clipboard): ProductCollectionServiceCopy to Clipboard

Parameters

NameType
transactionManager?Copy to ClipboardEntityManagerCopy to Clipboard

Returns

ProductCollectionServiceCopy to Clipboard

Inherited from

TransactionBaseService.withTransaction

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:14