ProductCollectionService
Provides layer to manipulate product collections.
Hierarchy
TransactionBaseService
↳
ProductCollectionService
Constructors
constructor
new ProductCollectionService(«destructured»
)
Parameters
Name |
---|
«destructured» |
Overrides
TransactionBaseService.constructor
Defined in
medusa/src/services/product-collection.ts:49
Properties
__configModule__
Protected
Optional
Readonly
__configModule__: Record<string
, unknown
>
Inherited from
TransactionBaseService.__configModule__
Defined in
medusa/src/interfaces/transaction-base-service.ts:14
__container__
Protected
Readonly
__container__: any
Inherited from
TransactionBaseService.__container__
Defined in
medusa/src/interfaces/transaction-base-service.ts:13
__moduleDeclaration__
Protected
Optional
Readonly
__moduleDeclaration__: Record<string
, unknown
>
Inherited from
TransactionBaseService.__moduleDeclaration__
Defined in
medusa/src/interfaces/transaction-base-service.ts:15
eventBus_
Protected
Readonly
eventBus_: EventBusService
Defined in
medusa/src/services/product-collection.ts:36
manager_
Protected
manager_: EntityManager
Inherited from
TransactionBaseService.manager_
Defined in
medusa/src/interfaces/transaction-base-service.ts:5
productCollectionRepository_
Protected
Readonly
productCollectionRepository_: Repository
<ProductCollection
> & { findAndCountByDiscountConditionId
: Method findAndCountByDiscountConditionId }
Defined in
medusa/src/services/product-collection.ts:38
productRepository_
Protected
Readonly
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 }
Defined in
medusa/src/services/product-collection.ts:39
transactionManager_
Protected
transactionManager_: undefined
| EntityManager
Inherited from
TransactionBaseService.transactionManager_
Defined in
medusa/src/interfaces/transaction-base-service.ts:6
Events
Static
Readonly
Events: Object
Type declaration
Name | Type |
---|---|
CREATED | string |
DELETED | string |
PRODUCTS_ADDED | string |
PRODUCTS_REMOVED | string |
UPDATED | string |
Defined in
medusa/src/services/product-collection.ts:41
Accessors
activeManager_
Protected
get
activeManager_(): EntityManager
Returns
EntityManager
-EntityManager
:
Inherited from
TransactionBaseService.activeManager_
Defined in
medusa/src/interfaces/transaction-base-service.ts:8
Methods
addProducts
addProducts(collectionId
, productIds
): Promise
<ProductCollection
>
Parameters
Name |
---|
collectionId |
productIds |
Returns
Promise
<ProductCollection
>
-Promise
:
-ProductCollection
:
Defined in
medusa/src/services/product-collection.ts:216
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.
Name |
---|
TResult |
TError |
Parameters
Name | Description |
---|---|
work | (transactionManager : EntityManager ) => Promise <TResult > |
isolationOrErrorHandler? | IsolationLevel | (error : TError ) => Promise <void | TResult > |
maybeErrorHandlerOrDontFail? | (error : TError ) => Promise <void | TResult > |
Returns
Promise
<TResult
>
-Promise
: the result of the transactional work
Inherited from
TransactionBaseService.atomicPhase_
Defined in
medusa/src/interfaces/transaction-base-service.ts:56
create
create(collection
): Promise
<ProductCollection
>
Creates a product collection
Parameters
Name | Description |
---|---|
collection | CreateProductCollection |
Returns
Promise
<ProductCollection
>
-Promise
: created collection
-ProductCollection
:
Defined in
medusa/src/services/product-collection.ts:128
delete
delete(collectionId
): Promise
<void
>
Deletes a product collection idempotently
Parameters
Name | Description |
---|---|
collectionId | string |
Returns
Promise
<void
>
-Promise
: empty promise
Defined in
medusa/src/services/product-collection.ts:192
list
list(selector?
, config?
): Promise
<ProductCollection
[]>
Lists product collections
Parameters
Name | Default value | Description |
---|---|---|
selector | Selector <ProductCollection > & { discount_condition_id? : string ; q? : string } | the query object for find |
config | object | the config to be used for find |
config.skip | number | 0 |
config.take | number | 20 |
Returns
Promise
<ProductCollection
[]>
-Promise
: the result of the find operation
-ProductCollection[]
:
-ProductCollection
:
Defined in
medusa/src/services/product-collection.ts:274
listAndCount
listAndCount(selector?
, config?
): Promise
<[ProductCollection
[], number
]>
Lists product collections and add count.
Parameters
Name | Description |
---|---|
selector | ListAndCountSelector |
config | FindConfig <ProductCollection > |
Returns
Promise
<[ProductCollection
[], number
]>
-Promise
: the result of the find operation
-ProductCollection[]
:
-number
: (optional)
Defined in
medusa/src/services/product-collection.ts:291
removeProducts
removeProducts(collectionId
, productIds
): Promise
<void
>
Parameters
Name |
---|
collectionId |
productIds |
Returns
Promise
<void
>
-Promise
:
Defined in
medusa/src/services/product-collection.ts:242
retrieve
retrieve(collectionId
, config?
): Promise
<ProductCollection
>
Retrieves a product collection by id.
Parameters
Name | Description |
---|---|
collectionId | string |
config | FindConfig <ProductCollection > |
Returns
Promise
<ProductCollection
>
-Promise
: the collection.
-ProductCollection
:
Defined in
medusa/src/services/product-collection.ts:68
retrieveByHandle
retrieveByHandle(collectionHandle
, config?
): Promise
<ProductCollection
>
Retrieves a product collection by id.
Parameters
Name | Description |
---|---|
collectionHandle | string |
config | FindConfig <ProductCollection > |
Returns
Promise
<ProductCollection
>
-Promise
: the collection.
-ProductCollection
:
Defined in
medusa/src/services/product-collection.ts:102
shouldRetryTransaction_
Protected
shouldRetryTransaction_(err
): boolean
Parameters
Name |
---|
err |
Returns
boolean
-boolean
: (optional)
Inherited from
TransactionBaseService.shouldRetryTransaction_
Defined in
medusa/src/interfaces/transaction-base-service.ts:37
update
update(collectionId
, update
): Promise
<ProductCollection
>
Updates a product collection
Parameters
Name | Description |
---|---|
collectionId | string |
update | UpdateProductCollection |
Returns
Promise
<ProductCollection
>
-Promise
: update collection
-ProductCollection
:
Defined in
medusa/src/services/product-collection.ts:154
withTransaction
withTransaction(transactionManager?
): ProductCollectionService
Parameters
Name |
---|
transactionManager? |
Returns
-ProductCollectionService
:
Inherited from
TransactionBaseService.withTransaction