CustomerGroupService
Constructors
constructor
**new CustomerGroupService**(«destructured»)
Parameters
Properties
__configModule__
Record<string, unknown>__container__
anyRequired__moduleDeclaration__
Record<string, unknown>customerGroupRepository_
Repository<CustomerGroup> & { addCustomers: Method addCustomers ; findWithRelationsAndCount: Method findWithRelationsAndCount ; removeCustomers: Method removeCustomers }Requiredmanager_
EntityManagerRequiredtransactionManager_
undefined | EntityManagerRequiredAccessors
activeManager_
Protected get**activeManager_**(): EntityManager
Returns
EntityManager
EntityManager
EntityManagerRequiredMethods
addCustomers
**addCustomers**(id, customerIds): Promise<[CustomerGroup](/references/services/classes/CustomerGroup)>
Add a batch of customers to a customer group at once
Parameters
id
stringRequiredcustomerIds
string | string[]RequiredReturns
Promise<CustomerGroup>
atomicPhase_
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**(group): Promise<[CustomerGroup](/references/services/classes/CustomerGroup)>
Creates a customer group with the provided data.
Parameters
Returns
Promise<CustomerGroup>
delete
**delete**(groupId): Promise<void>
Remove customer group
Parameters
groupId
stringRequiredReturns
Promise<void>
Promise
Promise<void>RequiredhandleCreationFail
Private **handleCreationFail**(id, ids, error): Promise<never>
Parameters
id
stringRequiredids
string[]Requirederror
anyRequiredReturns
Promise<never>
Promise
Promise<never>Requiredlist
**list**(selector?, config): Promise<[CustomerGroup](/references/services/classes/CustomerGroup)[]>
List customer groups.
Parameters
Default: {}
Returns
Promise<CustomerGroup[]>
listAndCount
**listAndCount**(selector?, config): Promise<[[CustomerGroup](/references/services/classes/CustomerGroup)[], number]>
Retrieve a list of customer groups and total count of records that match the query.
Parameters
Default: {}
Returns
Promise<[CustomerGroup[], number]>
removeCustomer
**removeCustomer**(id, customerIds): Promise<[CustomerGroup](/references/services/classes/CustomerGroup)>
Remove list of customers from a customergroup
Parameters
id
stringRequiredcustomerIds
string | string[]RequiredReturns
Promise<CustomerGroup>
retrieve
**retrieve**(customerGroupId, config?): Promise<[CustomerGroup](/references/services/classes/CustomerGroup)>
Parameters
customerGroupId
stringRequiredconfig
objectRequiredDefault: {}
Returns
Promise<CustomerGroup>
shouldRetryTransaction_
Protected **shouldRetryTransaction_**(err): boolean
Parameters
err
Record<string, unknown> | { code: string }RequiredReturns
boolean
boolean
booleanupdate
**update**(customerGroupId, update): Promise<[CustomerGroup](/references/services/classes/CustomerGroup)>
Update a customer group.
Parameters
customerGroupId
stringRequiredReturns
Promise<CustomerGroup>
withTransaction
**withTransaction**(transactionManager?): [CustomerGroupService](/references/services/classes/CustomerGroupService)
Parameters
transactionManager
EntityManager