Skip to main content
Skip to main content

ProductCategoryService

internal.internal.ProductCategoryService

Provides layer to manipulate product categories.

Properties

__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
eventBusService_EventBusServiceRequired
manager_EntityManagerRequired
productCategoryRepo_TreeRepository<ProductCategory> & { addProducts: Method addProducts ; findOneWithDescendants: Method findOneWithDescendants ; getFreeTextSearchResultsAndCount: Method getFreeTextSearchResultsAndCount ; removeProducts: Method removeProducts }Required
transactionManager_undefined | EntityManagerRequired
EventsobjectRequired
Events.CREATEDstringRequired
Events.DELETEDstringRequired
Events.UPDATEDstringRequired

Accessors

activeManager_

Protected get activeManager_(): EntityManager

Returns

EntityManager

EntityManagerEntityManagerRequired

Inherited from

TransactionBaseService.activeManager_

Methods

addProducts

addProducts(productCategoryId, productIds): Promise<void>

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

Promise<void>

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

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.

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

Promise<TResult>

PromisePromise<TResult>Required
the result of the transactional work

Inherited from

TransactionBaseService.atomicPhase_


create

create(productCategoryInput): Promise<ProductCategory>

Creates a product category

Parameters

productCategoryInputCreateProductCategoryInputRequired
parameters to create a product category

Returns

Promise<ProductCategory>

PromisePromise<ProductCategory>Required
created product category

delete

delete(productCategoryId): Promise<void>

Deletes a product category

Parameters

productCategoryIdstringRequired
is the id of the product category to delete

Returns

Promise<void>

PromisePromise<void>Required
a promise

fetchReorderConditions

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

Parameters

productCategoryProductCategoryRequired
shouldDeleteElementboolean

Returns

ReorderConditions

ReorderConditionsobjectRequired

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

Filter options for product category.
Configuration for query.
Filter options for product category tree relations

Returns

Promise<[ProductCategory[], number]>

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

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

Parameters

repositoryTreeRepository<ProductCategory> & { addProducts: Method addProducts ; findOneWithDescendants: Method findOneWithDescendants ; getFreeTextSearchResultsAndCount: Method getFreeTextSearchResultsAndCount ; removeProducts: Method removeProducts }Required
conditionsReorderConditionsRequired

Returns

Promise<void>

PromisePromise<void>Required

removeProducts

removeProducts(productCategoryId, productIds): Promise<void>

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

Promise<void>

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

retrieve

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

Retrieves a product category by id.

Parameters

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

Returns

Promise<ProductCategory>

PromisePromise<ProductCategory>Required
the product category.

retrieveByHandle

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

Retrieves a product category by handle.

Parameters

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

Returns

Promise<ProductCategory>

PromisePromise<ProductCategory>Required
the product category.

retrieve_

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

A generic retrieve for fining product categories by different attributes.

Parameters

the config of the product category to retrieve.

Returns

Promise<ProductCategory>

PromisePromise<ProductCategory>Required
the product category.

shiftSiblings

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

Parameters

repositoryTreeRepository<ProductCategory> & { addProducts: Method addProducts ; findOneWithDescendants: Method findOneWithDescendants ; getFreeTextSearchResultsAndCount: Method getFreeTextSearchResultsAndCount ; removeProducts: Method removeProducts }Required
conditionsReorderConditionsRequired

Returns

Promise<void>

PromisePromise<void>Required

shouldRetryTransaction_

Protected shouldRetryTransaction_(err): boolean

Parameters

errRecord<string, unknown> | { code: string }Required

Returns

boolean

booleanboolean

Inherited from

TransactionBaseService.shouldRetryTransaction_


transformParentIdToEntity

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

Accepts an input object and transforms product_category_id into product_category entity.

Parameters

params used to create/update

Returns

Promise<CreateProductCategoryInput | UpdateProductCategoryInput>

transformed productCategoryInput

update

update(productCategoryId, productCategoryInput): Promise<ProductCategory>

Updates a product category

Parameters

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

Returns

Promise<ProductCategory>

PromisePromise<ProductCategory>Required
updated product category

withTransaction

withTransaction(transactionManager?): ProductCategoryService

Parameters

transactionManagerEntityManager

Returns

ProductCategoryService

ProductCategoryServiceProductCategoryServiceRequired

Inherited from

TransactionBaseService.withTransaction

Was this section helpful?