Class: ProductCategoryService
Provides layer to manipulate product categories.
Hierarchy
TransactionBaseService
↳
ProductCategoryService
Constructors
constructor
• new ProductCategoryService(__namedParameters
)
Parameters
Name | Type |
---|---|
__namedParameters | InjectedDependencies |
Overrides
TransactionBaseService.constructor
Defined in
packages/medusa/src/services/product-category.ts:35
Properties
__configModule__
• Protected
Optional
Readonly
__configModule__: Record
<string
, unknown
>
Inherited from
TransactionBaseService.__configModule__
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:10
__container__
• Protected
Readonly
__container__: any
Inherited from
TransactionBaseService.__container__
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:9
__moduleDeclaration__
• Protected
Optional
Readonly
__moduleDeclaration__: Record
<string
, unknown
>
Inherited from
TransactionBaseService.__moduleDeclaration__
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:11
eventBusService_
• Protected
Readonly
eventBusService_: EventBusService
Defined in
packages/medusa/src/services/product-category.ts:25
manager_
• Protected
manager_: EntityManager
Overrides
TransactionBaseService.manager_
Defined in
packages/medusa/src/services/product-category.ts:27
productCategoryRepo_
• Protected
Readonly
productCategoryRepo_: typeof ProductCategoryRepository
Defined in
packages/medusa/src/services/product-category.ts:24
transactionManager_
• Protected
transactionManager_: undefined
| EntityManager
Overrides
TransactionBaseService.transactionManager_
Defined in
packages/medusa/src/services/product-category.ts:26
Events
▪ Static
Events: Object
Type declaration
Name | Type |
---|---|
CREATED | string |
DELETED | string |
UPDATED | string |
Defined in
packages/medusa/src/services/product-category.ts:29
Methods
addProducts
▸ addProducts(productCategoryId
, productIds
): Promise
<void
>
Add a batch of product to a product category
Parameters
Name | Type | Description |
---|---|---|
productCategoryId | string | The id of the product category on which to add the products |
productIds | string [] | The products ids to attach to the product category |
Returns
Promise
<void
>
the product category on which the products have been added
Defined in
packages/medusa/src/services/product-category.ts:227
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.
Type parameters
Name |
---|
TResult |
TError |
Parameters
Name | Type | Description |
---|---|---|
work | (transactionManager : EntityManager ) => Promise <TResult > | the transactional work to be done |
isolationOrErrorHandler? | IsolationLevel | (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
>
the result of the transactional work
Inherited from
TransactionBaseService.atomicPhase_
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:50
create
▸ create(productCategoryInput
): Promise
<ProductCategory
>
Creates a product category
Parameters
Name | Type |
---|---|
productCategoryInput | CreateProductCategoryInput |
Returns
Promise
<ProductCategory
>
created product category
Defined in
packages/medusa/src/services/product-category.ts:132
delete
▸ delete(productCategoryId
): Promise
<void
>
Deletes a product category
Parameters
Name | Type | Description |
---|---|---|
productCategoryId | string | is the id of the product category to delete |
Returns
Promise
<void
>
a promise
Defined in
packages/medusa/src/services/product-category.ts:191
listAndCount
▸ listAndCount(selector
, config?
, treeSelector?
): Promise
<[ProductCategory
[], number
]>
Lists product category based on the provided parameters and includes the count of product category that match the query.
Parameters
Name | Type |
---|---|
selector | QuerySelector <ProductCategory > |
config | FindConfig <ProductCategory > |
treeSelector | QuerySelector <ProductCategory > |
Returns
Promise
<[ProductCategory
[], number
]>
an array containing the product category as the first element and the total count of product category that matches the query as the second element.
Defined in
packages/medusa/src/services/product-category.ts:55
removeProducts
▸ removeProducts(productCategoryId
, productIds
): Promise
<void
>
Remove a batch of product from a product category
Parameters
Name | Type | Description |
---|---|---|
productCategoryId | string | The id of the product category on which to remove the products |
productIds | string [] | The products ids to remove from the product category |
Returns
Promise
<void
>
the product category on which the products have been removed
Defined in
packages/medusa/src/services/product-category.ts:245
retrieve
▸ retrieve(productCategoryId
, config?
, selector?
): Promise
<ProductCategory
>
Retrieves a product category by id.
Parameters
Name | Type | Description |
---|---|---|
productCategoryId | string | the id of the product category to retrieve. |
config | FindConfig <ProductCategory > | the config of the product category to retrieve. |
selector | Selector <ProductCategory > | - |
Returns
Promise
<ProductCategory
>
the product category.
Defined in
packages/medusa/src/services/product-category.ts:92
shouldRetryTransaction_
▸ Protected
shouldRetryTransaction_(err
): boolean
Parameters
Name | Type |
---|---|
err | Record <string , unknown > | { code : string } |
Returns
boolean
Inherited from
TransactionBaseService.shouldRetryTransaction_
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:31
update
▸ update(productCategoryId
, productCategoryInput
): Promise
<ProductCategory
>
Updates a product category
Parameters
Name | Type | Description |
---|---|---|
productCategoryId | string | id of product category to update |
productCategoryInput | UpdateProductCategoryInput | parameters to update in product category |
Returns
Promise
<ProductCategory
>
updated product category
Defined in
packages/medusa/src/services/product-category.ts:156
withTransaction
▸ withTransaction(transactionManager?
): ProductCategoryService
Parameters
Name | Type |
---|---|
transactionManager? | EntityManager |
Returns
Inherited from
TransactionBaseService.withTransaction
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:14