Skip to main content
Skip to main content

ProductCategoryService

Provides layer to manipulate product categories.

constructor

Parameters

__namedParametersInjectedDependenciesRequired

Properties

__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
eventBusService_EventBusServiceRequired
manager_EntityManagerRequired
productCategoryRepo_TreeRepository<ProductCategory> & objectRequired
transactionManager_undefined | EntityManagerRequired
EventsobjectRequired
Events.CREATEDstringRequired

Default: "product-category.created"

Events.DELETEDstringRequired

Default: "product-category.deleted"

Events.UPDATEDstringRequired

Default: "product-category.updated"


Accessors

activeManager_

Returns

EntityManagerEntityManagerRequired

Methods

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

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

create

Creates a product category

Parameters

productCategoryInputCreateProductCategoryInputRequired
parameters to create a product category

Returns

PromisePromise<ProductCategory>Required
created product category

delete

Deletes a product category

Parameters

productCategoryIdstringRequired
is the id of the product category to delete

Returns

PromisePromise<void>Required
a promise

fetchReorderConditions

Parameters

productCategoryProductCategoryRequired
inputUpdateProductCategoryInputRequired
shouldDeleteElementbooleanRequired

Default: false

Returns

ReorderConditionsReorderConditionsRequired

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.

performReordering

Parameters

repositoryTreeRepository<ProductCategory> & objectRequired
conditionsReorderConditionsRequired

Returns

PromisePromise<void>Required

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

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.

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.

shiftSiblings

Parameters

repositoryTreeRepository<ProductCategory> & objectRequired
conditionsReorderConditionsRequired

Returns

PromisePromise<void>Required

shouldRetryTransaction_

Parameters

errRecord<string, unknown> | objectRequired

Returns

booleanboolean

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

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

withTransaction

Parameters

transactionManagerEntityManager

Returns

ProductCategoryServiceobjectRequired
Provides layer to manipulate product categories.
Was this section helpful?