---
displayed_sidebar: servicesSidebar
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# CustomerGroupService
## Constructors
### constructor
`**new CustomerGroupService**(«destructured»)`
#### Parameters
## Properties
`",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "__container__",
"type": "`any`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "__moduleDeclaration__",
"type": "`Record`",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customerGroupRepository_",
"type": "Repository<[CustomerGroup](CustomerGroup.mdx)> & `{ addCustomers: Method addCustomers ; findWithRelationsAndCount: Method findWithRelationsAndCount ; removeCustomers: Method removeCustomers }`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customerService_",
"type": "[CustomerService](CustomerService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "manager_",
"type": "EntityManager",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "transactionManager_",
"type": "`undefined` \\| EntityManager",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
## Accessors
### activeManager\_
`Protected get**activeManager_**(): EntityManager`
#### Returns
EntityManager
## Methods
### addCustomers
`**addCustomers**(id, customerIds): Promise<[CustomerGroup](CustomerGroup.mdx)>`
Add a batch of customers to a customer group at once
#### Parameters
#### Returns
Promise<[CustomerGroup](CustomerGroup.mdx)>
___
### atomicPhase\_
`Protected **atomicPhase_**(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.
#### Parameters
Promise<TResult>",
"description": "the transactional work to be done",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "isolationOrErrorHandler",
"type": "`IsolationLevel` \\| (`error`: `TError`) => Promise<void \\| TResult>",
"description": "the isolation level to be used for the work.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "maybeErrorHandlerOrDontFail",
"type": "(`error`: `TError`) => Promise<void \\| TResult>",
"description": "Potential error handler",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise<TResult>
___
### create
`**create**(group): Promise<[CustomerGroup](CustomerGroup.mdx)>`
Creates a customer group with the provided data.
#### Parameters
#### Returns
Promise<[CustomerGroup](CustomerGroup.mdx)>
___
### delete
`**delete**(groupId): Promise<void>`
Remove customer group
#### Parameters
#### Returns
Promise<void>
___
### handleCreationFail
`Private **handleCreationFail**(id, ids, error): Promise<never>`
#### Parameters
#### Returns
Promise<never>
___
### list
`**list**(selector?, config): Promise<[CustomerGroup](CustomerGroup.mdx)[]>`
List customer groups.
#### Parameters
#### Returns
Promise<[CustomerGroup](CustomerGroup.mdx)[]>
___
### listAndCount
`**listAndCount**(selector?, config): Promise<[[CustomerGroup](CustomerGroup.mdx)[], number]>`
Retrieve a list of customer groups and total count of records that match the query.
#### Parameters
#### Returns
Promise<[[CustomerGroup](CustomerGroup.mdx)[], number]>
___
### removeCustomer
`**removeCustomer**(id, customerIds): Promise<[CustomerGroup](CustomerGroup.mdx)>`
Remove list of customers from a customergroup
#### Parameters
#### Returns
Promise<[CustomerGroup](CustomerGroup.mdx)>
___
### retrieve
`**retrieve**(customerGroupId, config?): Promise<[CustomerGroup](CustomerGroup.mdx)>`
#### Parameters
#### Returns
Promise<[CustomerGroup](CustomerGroup.mdx)>
___
### shouldRetryTransaction\_
`Protected **shouldRetryTransaction_**(err): boolean`
#### Parameters
` \\| `{ code: string }`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
`boolean`
___
### update
`**update**(customerGroupId, update): Promise<[CustomerGroup](CustomerGroup.mdx)>`
Update a customer group.
#### Parameters
#### Returns
Promise<[CustomerGroup](CustomerGroup.mdx)>
___
### withTransaction
`**withTransaction**(transactionManager?): [CustomerGroupService](CustomerGroupService.mdx)`
#### Parameters
#### Returns
[CustomerGroupService](CustomerGroupService.mdx)