Skip to main content

Class: CustomerGroupService

Provides layer to manipulate discounts.

implements {BaseService}

Hierarchy

  • "medusa-interfaces"

    CustomerGroupService

Constructors

constructor

new CustomerGroupService(__namedParameters)

Parameters

NameType
__namedParametersCustomerGroupConstructorProps

Overrides

BaseService.constructor

Defined in

services/customer-group.ts:31

Properties

customerGroupRepository_

Private customerGroupRepository_: typeof CustomerGroupRepository

Defined in

services/customer-group.ts:27


customerService_

Private customerService_: CustomerService

Defined in

services/customer-group.ts:29


manager_

Private manager_: EntityManager

Defined in

services/customer-group.ts:25

Methods

addCustomers

addCustomers(id, customerIds): Promise<CustomerGroup>

Add a batch of customers to a customer group at once

Parameters

NameTypeDescription
idstringid of the customer group to add customers to
customerIdsstring | string[]customer id's to add to the group

Returns

Promise<CustomerGroup>

the customer group after insertion

Defined in

services/customer-group.ts:113


create

create(group): Promise<CustomerGroup>

Creates a customer group with the provided data.

Parameters

NameTypeDescription
groupDeepPartial<CustomerGroup>the customer group to create

Returns

Promise<CustomerGroup>

the result of the create operation

Defined in

services/customer-group.ts:86


delete

delete(groupId): Promise<void>

Remove customer group

Parameters

NameTypeDescription
groupIdstringid of the customer group to delete

Returns

Promise<void>

a promise

Defined in

services/customer-group.ts:194


list

list(selector?, config): Promise<CustomerGroup[]>

List customer groups.

Parameters

NameTypeDescription
selectorFilterableCustomerGroupPropsthe query object for find
configFindConfig<CustomerGroup>the config to be used for find

Returns

Promise<CustomerGroup[]>

the result of the find operation

Defined in

services/customer-group.ts:217


listAndCount

listAndCount(selector?, config): Promise<[CustomerGroup[], number]>

Retrieve a list of customer groups and total count of records that match the query.

Parameters

NameTypeDescription
selectorFilterableCustomerGroupPropsthe query object for find
configFindConfig<CustomerGroup>the config to be used for find

Returns

Promise<[CustomerGroup[], number]>

the result of the find operation

Defined in

services/customer-group.ts:236


removeCustomer

removeCustomer(id, customerIds): Promise<CustomerGroup>

Remove list of customers from a customergroup

Parameters

NameTypeDescription
idstringid of the customer group from which the customers are removed
customerIdsstring | string[]id's of the customer to remove from group

Returns

Promise<CustomerGroup>

the customergroup with the provided id

Defined in

services/customer-group.ts:271


retrieve

retrieve(id, config?): Promise<CustomerGroup>

Parameters

NameType
idstring
configObject

Returns

Promise<CustomerGroup>

Defined in

services/customer-group.ts:62


update

update(customerGroupId, update): Promise<CustomerGroup[]>

Update a customer group.

Parameters

NameTypeDescription
customerGroupIdstringid of the customer group
updateCustomerGroupUpdatecustomer group partial data

Returns

Promise<CustomerGroup[]>

resulting customer group

Defined in

services/customer-group.ts:162


withTransaction

withTransaction(transactionManager): CustomerGroupService

Parameters

NameType
transactionManagerEntityManager

Returns

CustomerGroupService

Defined in

services/customer-group.ts:46