ProductCategoryService
internal.internal.ProductCategoryService
Provides layer to manipulate product categories.
Properties
__configModule__Record<string, unknown>__container__anyRequired__moduleDeclaration__Record<string, unknown>manager_EntityManagerRequiredproductCategoryRepo_TreeRepository<ProductCategory> & { addProducts: Method addProducts ; findOneWithDescendants: Method findOneWithDescendants ; getFreeTextSearchResultsAndCount: Method getFreeTextSearchResultsAndCount ; removeProducts: Method removeProducts }RequiredtransactionManager_undefined | EntityManagerRequiredEventsobjectRequiredEvents.CREATEDstringRequiredEvents.DELETEDstringRequiredEvents.UPDATEDstringRequiredAccessors
activeManager_
Protected get activeManager_(): EntityManager
Returns
EntityManager
EntityManagerEntityManagerRequiredInherited from
TransactionBaseService.activeManager_
Methods
addProducts
addProducts(productCategoryId, productIds): Promise<void>
Add a batch of product to a product category
Parameters
productCategoryIdstringRequiredproductIdsstring[]RequiredReturns
Promise<void>
PromisePromise<void>RequiredatomicPhase_
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.
TResultobjectRequiredTErrorobjectRequiredParameters
work(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandlerIsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail(error: TError) => Promise<void | TResult>Returns
Promise<TResult>
PromisePromise<TResult>RequiredInherited from
TransactionBaseService.atomicPhase_
create
create(productCategoryInput): Promise<ProductCategory>
Creates a product category
Parameters
Returns
Promise<ProductCategory>
created product category
delete
delete(productCategoryId): Promise<void>
Deletes a product category
Parameters
productCategoryIdstringRequiredReturns
Promise<void>
PromisePromise<void>RequiredfetchReorderConditions
Protected fetchReorderConditions(productCategory, input, shouldDeleteElement?): ReorderConditions
Parameters
shouldDeleteElementbooleanReturns
ReorderConditionsobjectRequiredlistAndCount
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
configFindConfig<ProductCategory>treeSelectorQuerySelector<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.
performReordering
Protected performReordering(repository, conditions): Promise<void>
Parameters
repositoryTreeRepository<ProductCategory> & { addProducts: Method addProducts ; findOneWithDescendants: Method findOneWithDescendants ; getFreeTextSearchResultsAndCount: Method getFreeTextSearchResultsAndCount ; removeProducts: Method removeProducts }RequiredReturns
Promise<void>
PromisePromise<void>RequiredremoveProducts
removeProducts(productCategoryId, productIds): Promise<void>
Remove a batch of product from a product category
Parameters
productCategoryIdstringRequiredproductIdsstring[]RequiredReturns
Promise<void>
PromisePromise<void>Requiredretrieve
retrieve(productCategoryId, config?, selector?, treeSelector?): Promise<ProductCategory>
Retrieves a product category by id.
Parameters
productCategoryIdstringRequiredconfigFindConfig<ProductCategory>selectorSelector<ProductCategory>treeSelectorQuerySelector<ProductCategory>Returns
Promise<ProductCategory>
the product category.
retrieveByHandle
retrieveByHandle(handle, config?, selector?, treeSelector?): Promise<ProductCategory>
Retrieves a product category by handle.
Parameters
handlestringRequiredconfigFindConfig<ProductCategory>selectorSelector<ProductCategory>treeSelectorQuerySelector<ProductCategory>Returns
Promise<ProductCategory>
the product category.
retrieve_
Protected retrieve_(config?, selector?, treeSelector?): Promise<ProductCategory>
A generic retrieve for fining product categories by different attributes.
Parameters
configFindConfig<ProductCategory>selectorSelector<ProductCategory>treeSelectorQuerySelector<ProductCategory>Returns
Promise<ProductCategory>
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 }RequiredReturns
Promise<void>
PromisePromise<void>RequiredshouldRetryTransaction_
Protected shouldRetryTransaction_(err): boolean
Parameters
errRecord<string, unknown> | { code: string }RequiredReturns
boolean
booleanbooleanInherited from
TransactionBaseService.shouldRetryTransaction_
transformParentIdToEntity
Protected transformParentIdToEntity(productCategoryInput): Promise<CreateProductCategoryInput | UpdateProductCategoryInput>
Accepts an input object and transforms product_category_id into product_category entity.
Parameters
Returns
Promise<CreateProductCategoryInput | UpdateProductCategoryInput>
transformed productCategoryInput
update
update(productCategoryId, productCategoryInput): Promise<ProductCategory>
Updates a product category
Parameters
productCategoryIdstringRequiredReturns
Promise<ProductCategory>
updated product category
withTransaction
withTransaction(transactionManager?): ProductCategoryService
Parameters
transactionManagerEntityManager