Skip to main content
Skip to main content

ProductCategoryService

Provides layer to manipulate product categories.

Hierarchy

  • TransactionBaseService

    ProductCategoryService

Constructors

constructor

new ProductCategoryService(«destructured»)

Parameters

Name
«destructured»

Overrides

TransactionBaseService.constructor

Defined in

medusa/src/services/product-category.ts:40

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


eventBusService_

Protected Readonly eventBusService_: EventBusService

Defined in

medusa/src/services/product-category.ts:32


manager_

Protected manager_: EntityManager

Inherited from

TransactionBaseService.manager_

Defined in

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


productCategoryRepo_

Protected Readonly productCategoryRepo_: TreeRepository<ProductCategory> & { addProducts: Method addProducts ; findOneWithDescendants: Method findOneWithDescendants ; getFreeTextSearchResultsAndCount: Method getFreeTextSearchResultsAndCount ; removeProducts: Method removeProducts }

Defined in

medusa/src/services/product-category.ts:31


transactionManager_

Protected transactionManager_: undefined | EntityManager

Inherited from

TransactionBaseService.transactionManager_

Defined in

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


Events

Static Events: Object

Type declaration

NameType
CREATEDstring
DELETEDstring
UPDATEDstring

Defined in

medusa/src/services/product-category.ts:34

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(productCategoryId, productIds): Promise<void>

Add a batch of product to a product category

Parameters

NameDescription
productCategoryIdstring
productIdsstring[]

Returns

Promise<void>

-Promise: the product category on which the products have been added

Defined in

medusa/src/services/product-category.ts:314


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

NameDescription
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(productCategoryInput): Promise<ProductCategory>

Creates a product category

Parameters

NameDescription
productCategoryInputCreateProductCategoryInput

Returns

Promise<ProductCategory>

-Promise: created product category -ProductCategory:

Defined in

medusa/src/services/product-category.ts:187


delete

delete(productCategoryId): Promise<void>

Deletes a product category

Parameters

NameDescription
productCategoryIdstring

Returns

Promise<void>

-Promise: a promise

Defined in

medusa/src/services/product-category.ts:268


fetchReorderConditions

Protected fetchReorderConditions(productCategory, input, shouldDeleteElement?): ReorderConditions

Parameters

NameDefault value
productCategoryProductCategory
inputUpdateProductCategoryInput
shouldDeleteElementboolean

Returns

ReorderConditions

Defined in

medusa/src/services/product-category.ts:349


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

NameDescription
selectorTreeQuerySelector<ProductCategory>
configFindConfig<ProductCategory>
treeSelectorQuerySelector<ProductCategory>

Returns

Promise<[ProductCategory[], number]>

-Promise: 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. -ProductCategory[]: -number: (optional)

Defined in

medusa/src/services/product-category.ts:61


performReordering

Protected performReordering(repository, conditions): Promise<void>

Parameters

Name
repository
conditions

Returns

Promise<void>

-Promise:

Defined in

medusa/src/services/product-category.ts:377


removeProducts

removeProducts(productCategoryId, productIds): Promise<void>

Remove a batch of product from a product category

Parameters

NameDescription
productCategoryIdstring
productIdsstring[]

Returns

Promise<void>

-Promise: the product category on which the products have been removed

Defined in

medusa/src/services/product-category.ts:333


retrieve

retrieve(productCategoryId, config?, selector?, treeSelector?): Promise<ProductCategory>

Retrieves a product category by id.

Parameters

NameDescription
productCategoryIdstring
configFindConfig<ProductCategory>
selectorSelector<ProductCategory>
treeSelectorQuerySelector<ProductCategory>

Returns

Promise<ProductCategory>

-Promise: the product category. -ProductCategory:

Defined in

medusa/src/services/product-category.ts:139


retrieveByHandle

retrieveByHandle(handle, config?, selector?, treeSelector?): Promise<ProductCategory>

Retrieves a product category by handle.

Parameters

NameDescription
handlestring
configFindConfig<ProductCategory>
selectorSelector<ProductCategory>
treeSelectorQuerySelector<ProductCategory>

Returns

Promise<ProductCategory>

-Promise: the product category. -ProductCategory:

Defined in

medusa/src/services/product-category.ts:165


retrieve_

Protected retrieve_(config?, selector?, treeSelector?): Promise<ProductCategory>

A generic retrieve for fining product categories by different attributes.

Parameters

NameDescription
configFindConfig<ProductCategory>
selectorSelector<ProductCategory>
treeSelectorQuerySelector<ProductCategory>

Returns

Promise<ProductCategory>

-Promise: the product category. -ProductCategory:

Defined in

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


shiftSiblings

Protected shiftSiblings(repository, conditions): Promise<void>

Parameters

Name
repository
conditions

Returns

Promise<void>

-Promise:

Defined in

medusa/src/services/product-category.ts:415


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


transformParentIdToEntity

Protected transformParentIdToEntity(productCategoryInput): Promise<CreateProductCategoryInput | UpdateProductCategoryInput>

Accepts an input object and transforms product_category_id into product_category entity.

Parameters

NameDescription
productCategoryInputCreateProductCategoryInput | UpdateProductCategoryInput

Returns

Promise<CreateProductCategoryInput | UpdateProductCategoryInput>

-Promise: transformed productCategoryInput -CreateProductCategoryInput \| UpdateProductCategoryInput: (optional)

Defined in

medusa/src/services/product-category.ts:513


update

update(productCategoryId, productCategoryInput): Promise<ProductCategory>

Updates a product category

Parameters

NameDescription
productCategoryIdstring
productCategoryInputUpdateProductCategoryInput

Returns

Promise<ProductCategory>

-Promise: updated product category -ProductCategory:

Defined in

medusa/src/services/product-category.ts:221


withTransaction

withTransaction(transactionManager?): ProductCategoryService

Parameters

Name
transactionManager?

Returns

ProductCategoryService

-ProductCategoryService:

Inherited from

TransactionBaseService.withTransaction

Defined in

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

Was this section helpful?