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 | EntityManagerRequiredEvents
objectRequiredEvents.CREATED
stringRequiredEvents.DELETED
stringRequiredEvents.UPDATED
stringRequiredAccessors
activeManager_
Protected
get
activeManager_(): EntityManager
Returns
EntityManager
EntityManager
EntityManagerRequiredInherited from
TransactionBaseService.activeManager_
Methods
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_<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.
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>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
productCategoryId
stringRequiredReturns
Promise
<void
>
Promise
Promise<void>RequiredfetchReorderConditions
Protected
fetchReorderConditions(productCategory
, input
, shouldDeleteElement?
): ReorderConditions
Parameters
shouldDeleteElement
booleanReturns
ReorderConditions
objectRequiredlistAndCount
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
config
FindConfig<ProductCategory>treeSelector
QuerySelector<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
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
>
Retrieves a product category by id.
Parameters
productCategoryId
stringRequiredconfig
FindConfig<ProductCategory>selector
Selector<ProductCategory>treeSelector
QuerySelector<ProductCategory>Returns
Promise
<ProductCategory
>
the product category.
retrieveByHandle
retrieveByHandle(handle
, config?
, selector?
, treeSelector?
): Promise
<ProductCategory
>
Retrieves a product category by handle.
Parameters
handle
stringRequiredconfig
FindConfig<ProductCategory>selector
Selector<ProductCategory>treeSelector
QuerySelector<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
config
FindConfig<ProductCategory>selector
Selector<ProductCategory>treeSelector
QuerySelector<ProductCategory>Returns
Promise
<ProductCategory
>
the product category.
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
booleanInherited 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
productCategoryId
stringRequiredReturns
Promise
<ProductCategory
>
updated product category
withTransaction
withTransaction(transactionManager?
): ProductCategoryService
Parameters
transactionManager
EntityManager