ProductCategoryService
Provides layer to manipulate product categories.
Constructors
constructor
**new ProductCategoryService**(«destructured»)
Parameters
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 | EntityManagerRequiredEvents
objectRequiredEvents.CREATED
stringRequiredDefault: "product-category.created"
Events.DELETED
stringRequiredDefault: "product-category.deleted"
Events.UPDATED
stringRequiredDefault: "product-category.updated"
Accessors
activeManager_
Protected get**activeManager_**(): EntityManager
Returns
EntityManager
EntityManager
EntityManagerRequiredMethods
addProducts
**addProducts**(productCategoryId, productIds): Promise<void>
Add a batch of product to a product category
Parameters
productCategoryId
stringRequiredproductIds
string[]RequiredReturns
Promise<void>
Promise
Promise<void>RequiredatomicPhase_
Protected **atomicPhase_**<TypeParameter TResult, TypeParameter 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.
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Returns
Promise<TResult>
Promise
Promise<TResult>Requiredcreate
**create**(productCategoryInput): Promise<[ProductCategory](/references/services/classes/ProductCategory)>
Creates a product category
Parameters
Returns
Promise<ProductCategory>
delete
**delete**(productCategoryId): Promise<void>
Deletes a product category
Parameters
productCategoryId
stringRequiredReturns
Promise<void>
Promise
Promise<void>RequiredfetchReorderConditions
Protected **fetchReorderConditions**(productCategory, input, shouldDeleteElement?): [ReorderConditions](/references/services/types/ReorderConditions)
Parameters
shouldDeleteElement
booleanRequiredDefault: false
Returns
ReorderConditions
objectRequiredlistAndCount
**listAndCount**(selector, config?, treeSelector?): Promise<[[ProductCategory](/references/services/classes/ProductCategory)[], number]>
Lists product category based on the provided parameters and includes the count of product category that match the query.
Parameters
Default: {}
Returns
Promise<[ProductCategory[], number]>
performReordering
Protected **performReordering**(repository, conditions): Promise<void>
Parameters
repository
TreeRepository<ProductCategory> & { addProducts: Method addProducts ; findOneWithDescendants: Method findOneWithDescendants ; getFreeTextSearchResultsAndCount: Method getFreeTextSearchResultsAndCount ; removeProducts: Method removeProducts }RequiredReturns
Promise<void>
Promise
Promise<void>RequiredremoveProducts
**removeProducts**(productCategoryId, productIds): Promise<void>
Remove a batch of product from a product category
Parameters
productCategoryId
stringRequiredproductIds
string[]RequiredReturns
Promise<void>
Promise
Promise<void>Requiredretrieve
**retrieve**(productCategoryId, config?, selector?, treeSelector?): Promise<[ProductCategory](/references/services/classes/ProductCategory)>
Retrieves a product category by id.
Parameters
productCategoryId
stringRequiredDefault: {}
Default: {}
Default: {}
Returns
Promise<ProductCategory>
retrieveByHandle
**retrieveByHandle**(handle, config?, selector?, treeSelector?): Promise<[ProductCategory](/references/services/classes/ProductCategory)>
Retrieves a product category by handle.
Parameters
handle
stringRequiredDefault: {}
Default: {}
Default: {}
Returns
Promise<ProductCategory>
retrieve_
Protected **retrieve_**(config?, selector?, treeSelector?): Promise<[ProductCategory](/references/services/classes/ProductCategory)>
A generic retrieve for fining product categories by different attributes.
Parameters
Default: {}
Default: {}
Default: {}
Returns
Promise<ProductCategory>
shiftSiblings
Protected **shiftSiblings**(repository, conditions): Promise<void>
Parameters
repository
TreeRepository<ProductCategory> & { addProducts: Method addProducts ; findOneWithDescendants: Method findOneWithDescendants ; getFreeTextSearchResultsAndCount: Method getFreeTextSearchResultsAndCount ; removeProducts: Method removeProducts }RequiredReturns
Promise<void>
Promise
Promise<void>RequiredshouldRetryTransaction_
Protected **shouldRetryTransaction_**(err): boolean
Parameters
err
Record<string, unknown> | { code: string }RequiredReturns
boolean
boolean
booleantransformParentIdToEntity
Protected **transformParentIdToEntity**(productCategoryInput): Promise<[CreateProductCategoryInput](/references/services/types/CreateProductCategoryInput) \| [UpdateProductCategoryInput](/references/services/types/UpdateProductCategoryInput)>
Accepts an input object and transforms product_category_id into product_category entity.
Parameters
Returns
Promise<CreateProductCategoryInput | UpdateProductCategoryInput>
update
**update**(productCategoryId, productCategoryInput): Promise<[ProductCategory](/references/services/classes/ProductCategory)>
Updates a product category
Parameters
productCategoryId
stringRequiredReturns
Promise<ProductCategory>
withTransaction
**withTransaction**(transactionManager?): [ProductCategoryService](/references/services/classes/ProductCategoryService)
Parameters
transactionManager
EntityManager