Skip to main content
Skip to main content

ProductCategoryService

Provides layer to manipulate product categories.

constructor

Parameters

__namedParametersInjectedDependenciesRequired

Properties

manager_EntityManagerRequired
transactionManager_undefined | EntityManagerRequired
__container__anyRequired
productCategoryRepo_TreeRepository<ProductCategory> & objectRequired
eventBusService_EventBusServiceRequired
EventsobjectRequired
Events.CREATEDstringRequired

Default: "product-category.created"

Events.UPDATEDstringRequired

Default: "product-category.updated"

Events.DELETEDstringRequired

Default: "product-category.deleted"

__configModule__Record<string, unknown>
__moduleDeclaration__Record<string, unknown>

Accessors

activeManager_

Returns

EntityManagerEntityManagerRequired

Methods

withTransaction

Parameters

transactionManagerEntityManager

Returns

thisthisRequired

shouldRetryTransaction_

Parameters

errRecord<string, unknown> | objectRequired

Returns

booleanbooleanRequired

atomicPhase_

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

TResultobjectRequired
TErrorobjectRequired

Parameters

work(transactionManager: EntityManager) => Promise<TResult>Required
the transactional work to be done
isolationOrErrorHandlerIsolationLevel | (error: TError) => Promise<void | TResult>
the isolation level to be used for the work.
maybeErrorHandlerOrDontFail(error: TError) => Promise<void | TResult>
Potential error handler

Returns

PromisePromise<TResult>Required
the result of the transactional work

listAndCount

Lists product category based on the provided parameters and includes the count of product category that match the query.

Parameters

Filter options for product category.
Configuration for query.
treeSelectorQuerySelector<ProductCategory>Required
Filter options for product category tree relations

Default: {}

Returns

PromisePromise<[ProductCategory[], number]>Required
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.

retrieve_

A generic retrieve for fining product categories by different attributes.

Parameters

the config of the product category to retrieve.

Default: {}

selectorSelector<ProductCategory>Required

Default: {}

treeSelectorQuerySelector<ProductCategory>Required

Default: {}

Returns

PromisePromise<ProductCategory>Required
the product category.

retrieve

Retrieves a product category by id.

Parameters

productCategoryIdstringRequired
the id of the product category to retrieve.
the config of the product category to retrieve.

Default: {}

selectorSelector<ProductCategory>Required

Default: {}

treeSelectorQuerySelector<ProductCategory>Required

Default: {}

Returns

PromisePromise<ProductCategory>Required
the product category.

retrieveByHandle

Retrieves a product category by handle.

Parameters

handlestringRequired
the handle of the category
the config of the product category to retrieve.

Default: {}

selectorSelector<ProductCategory>Required

Default: {}

treeSelectorQuerySelector<ProductCategory>Required

Default: {}

Returns

PromisePromise<ProductCategory>Required
the product category.

create

Creates a product category

Parameters

productCategoryInputCreateProductCategoryInputRequired
parameters to create a product category

Returns

PromisePromise<ProductCategory>Required
created product category

update

Updates a product category

Parameters

productCategoryIdstringRequired
id of product category to update
productCategoryInputUpdateProductCategoryInputRequired
parameters to update in product category

Returns

PromisePromise<ProductCategory>Required
updated product category

delete

Deletes a product category

Parameters

productCategoryIdstringRequired
is the id of the product category to delete

Returns

PromisePromise<void>Required
a promise

addProducts

Add a batch of product to a product category

Parameters

productCategoryIdstringRequired
The id of the product category on which to add the products
productIdsstring[]Required
The products ids to attach to the product category

Returns

PromisePromise<void>Required
the product category on which the products have been added

removeProducts

Remove a batch of product from a product category

Parameters

productCategoryIdstringRequired
The id of the product category on which to remove the products
productIdsstring[]Required
The products ids to remove from the product category

Returns

PromisePromise<void>Required
the product category on which the products have been removed

fetchReorderConditions

Parameters

productCategoryProductCategoryRequired
inputUpdateProductCategoryInputRequired
shouldDeleteElementbooleanRequired

Default: false

Returns

ReorderConditionsReorderConditionsRequired

performReordering

Parameters

repositoryTreeRepository<ProductCategory> & objectRequired
conditionsReorderConditionsRequired

Returns

PromisePromise<void>Required

shiftSiblings

Parameters

repositoryTreeRepository<ProductCategory> & objectRequired
conditionsReorderConditionsRequired

Returns

PromisePromise<void>Required

transformParentIdToEntity

Accepts an input object and transforms product_category_id into product_category entity.

Parameters

productCategoryInputCreateProductCategoryInput | UpdateProductCategoryInputRequired
params used to create/update

Returns

PromisePromise<CreateProductCategoryInput | UpdateProductCategoryInput>Required
transformed productCategoryInput
Was this section helpful?