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

medusa/src/services/product-collection.ts:49

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

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


__container__

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard __container__: anyCopy to Clipboard

Inherited from

TransactionBaseService.__container__

Defined in

medusa/src/interfaces/transaction-base-service.ts:13


__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

medusa/src/interfaces/transaction-base-service.ts:15


eventBus_

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard eventBus_: EventBusServiceCopy to Clipboard

Defined in

medusa/src/services/product-collection.ts:36


manager_

ProtectedCopy to Clipboard manager_: EntityManagerCopy to Clipboard

Inherited from

TransactionBaseService.manager_

Defined in

medusa/src/interfaces/transaction-base-service.ts:5


productCollectionRepository_

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard productCollectionRepository_: RepositoryCopy to Clipboard<ProductCollectionCopy to Clipboard> & { findAndCountByDiscountConditionIdCopy to Clipboard: (conditionIdCopy to Clipboard: stringCopy to Clipboard, queryCopy to Clipboard: ExtendedFindConfigCopy to Clipboard<ProductCollectionCopy to Clipboard>) => PromiseCopy to Clipboard<[ProductCollectionCopy to Clipboard[], numberCopy to Clipboard]> }

Defined in

medusa/src/services/product-collection.ts:38


productRepository_

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard productRepository_: RepositoryCopy to Clipboard<ProductCopy to Clipboard> & { _applyCategoriesQueryCopy to Clipboard: (qbCopy to Clipboard: SelectQueryBuilderCopy to Clipboard<ProductCopy to Clipboard>, __namedParametersCopy to Clipboard: ObjectCopy to Clipboard) => SelectQueryBuilderCopy to Clipboard<ProductCopy to Clipboard> ; _findWithRelationsCopy to Clipboard: (__namedParametersCopy to Clipboard: { idsOrOptionsWithoutRelationsCopy to Clipboard: stringCopy to Clipboard[] | FindWithoutRelationsOptionsCopy to Clipboard ; relationsCopy to Clipboard: stringCopy to Clipboard[] ; shouldCountCopy to Clipboard: booleanCopy to Clipboard ; withDeletedCopy to Clipboard: booleanCopy to Clipboard }) => PromiseCopy to Clipboard<[ProductCopy to Clipboard[], numberCopy to Clipboard]> ; bulkAddToCollectionCopy to Clipboard: (productIdsCopy to Clipboard: stringCopy to Clipboard[], collectionIdCopy to Clipboard: stringCopy to Clipboard) => PromiseCopy to Clipboard<ProductCopy to Clipboard[]> ; bulkRemoveFromCollectionCopy to Clipboard: (productIdsCopy to Clipboard: stringCopy to Clipboard[], collectionIdCopy to Clipboard: stringCopy to Clipboard) => PromiseCopy to Clipboard<ProductCopy to Clipboard[]> ; findOneWithRelationsCopy to Clipboard: (relationsCopy to Clipboard: stringCopy to Clipboard[], optionsWithoutRelationsCopy to Clipboard: FindWithoutRelationsOptionsCopy to Clipboard) => PromiseCopy to Clipboard<ProductCopy to Clipboard> ; findWithRelationsCopy to Clipboard: (relationsCopy to Clipboard: stringCopy to Clipboard[], idsOrOptionsWithoutRelationsCopy to Clipboard: stringCopy to Clipboard[] | FindWithoutRelationsOptionsCopy to Clipboard, withDeletedCopy to Clipboard: booleanCopy to Clipboard) => PromiseCopy to Clipboard<ProductCopy to Clipboard[]> ; findWithRelationsAndCountCopy to Clipboard: (relationsCopy to Clipboard: stringCopy to Clipboard[], idsOrOptionsWithoutRelationsCopy to Clipboard: FindWithoutRelationsOptionsCopy to Clipboard) => PromiseCopy to Clipboard<[ProductCopy to Clipboard[], numberCopy to Clipboard]> ; getFreeTextSearchResultsAndCountCopy to Clipboard: (qCopy to Clipboard: stringCopy to Clipboard, optionsCopy to Clipboard: FindWithoutRelationsOptionsCopy to Clipboard, relationsCopy to Clipboard: stringCopy to Clipboard[]) => PromiseCopy to Clipboard<[ProductCopy to Clipboard[], numberCopy to Clipboard]> ; isProductInSalesChannelsCopy to Clipboard: (idCopy to Clipboard: stringCopy to Clipboard, salesChannelIdsCopy to Clipboard: stringCopy to Clipboard[]) => PromiseCopy to Clipboard<booleanCopy to Clipboard> ; queryProductsCopy to Clipboard: (optionsWithoutRelationsCopy to Clipboard: FindWithoutRelationsOptionsCopy to Clipboard, shouldCountCopy to Clipboard: booleanCopy to Clipboard) => PromiseCopy to Clipboard<[ProductCopy to Clipboard[], numberCopy to Clipboard]> ; queryProductsWithIdsCopy to Clipboard: (__namedParametersCopy to Clipboard: { entityIdsCopy to Clipboard: stringCopy to Clipboard[] ; groupedRelationsCopy to Clipboard: { [toplevel: string]Copy to Clipboard: stringCopy to Clipboard[]; } ; order?Copy to Clipboard: { [column: string]Copy to Clipboard: "ASC"Copy to Clipboard | "DESC"Copy to Clipboard; } ; select?Copy to Clipboard: keyof ProductCopy to Clipboard[] ; where?Copy to Clipboard: FindOptionsWhereCopy to Clipboard<ProductCopy to Clipboard> ; withDeleted?Copy to Clipboard: booleanCopy to Clipboard }) => PromiseCopy to Clipboard<ProductCopy to Clipboard[]> ; upsertShippingProfileCopy to Clipboard: (productIdsCopy to Clipboard: stringCopy to Clipboard[], shippingProfileIdCopy to Clipboard: stringCopy to Clipboard) => PromiseCopy to Clipboard<ProductCopy to Clipboard[]> }

Defined in

medusa/src/services/product-collection.ts:39


transactionManager_

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

Inherited from

TransactionBaseService.transactionManager_

Defined in

medusa/src/interfaces/transaction-base-service.ts:6


Events

StaticCopy to Clipboard ReadonlyCopy to Clipboard Events: ObjectCopy to Clipboard

Type declaration

NameType
CREATEDCopy to ClipboardstringCopy to Clipboard
DELETEDCopy to ClipboardstringCopy to Clipboard
PRODUCTS_ADDEDCopy to ClipboardstringCopy to Clipboard
PRODUCTS_REMOVEDCopy to ClipboardstringCopy to Clipboard
UPDATEDCopy to ClipboardstringCopy to Clipboard

Defined in

medusa/src/services/product-collection.ts:41

Accessors

activeManager_

ProtectedCopy to Clipboard getCopy to Clipboard activeManager_(): EntityManagerCopy to Clipboard

Returns

EntityManagerCopy to Clipboard

Inherited from

TransactionBaseService.activeManager_

Defined in

medusa/src/interfaces/transaction-base-service.ts:8

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

medusa/src/services/product-collection.ts:216


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

medusa/src/interfaces/transaction-base-service.ts:56


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

medusa/src/services/product-collection.ts:128


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

medusa/src/services/product-collection.ts:192


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

medusa/src/services/product-collection.ts:274


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 ClipboardListAndCountSelectorCopy to Clipboardthe 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

medusa/src/services/product-collection.ts:291


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

medusa/src/services/product-collection.ts:242


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

medusa/src/services/product-collection.ts:68


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

medusa/src/services/product-collection.ts:102


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

medusa/src/interfaces/transaction-base-service.ts:37


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

medusa/src/services/product-collection.ts:154


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

medusa/src/interfaces/transaction-base-service.ts:20

Was this page helpful?