Skip to main content
Skip to main content

SalesChannelService

constructor

Parameters

__namedParametersInjectedDependenciesRequired

Properties

manager_EntityManagerRequired
transactionManager_undefined | EntityManagerRequired
__container__anyRequired
EventsobjectRequired
Events.UPDATEDstringRequired

Default: "sales_channel.updated"

Events.CREATEDstringRequired

Default: "sales_channel.created"

Events.DELETEDstringRequired

Default: "sales_channel.deleted"

salesChannelRepository_Repository<SalesChannel> & objectRequired
eventBusService_EventBusServiceRequired
storeService_StoreServiceRequired
featureFlagRouter_FlagRouterRequired
__configModule__Record<string, unknown>
__moduleDeclaration__Record<string, unknown>

Accessors

activeManager_

Returns

EntityManagerEntityManagerRequired

Methods

withTransaction

Parameters

transactionManagerEntityManager

Returns

thisthisRequired

shouldRetryTransaction_

Parameters

errRecord<string, unknown> | objectRequired

Returns

booleanbooleanRequired

atomicPhase_

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.

Type Parameters

TResultobjectRequired
TErrorobjectRequired

Parameters

work(transactionManager: EntityManager) => Promise<TResult>Required
the transactional work to be done
isolationOrErrorHandlerIsolationLevel | (error: TError) => Promise<void | TResult>
the isolation level to be used for the work.
maybeErrorHandlerOrDontFail(error: TError) => Promise<void | TResult>
Potential error handler

Returns

PromisePromise<TResult>Required
the result of the transactional work

retrieve_

A generic retrieve used to find a sales channel by different attributes.

Parameters

selectorSelector<SalesChannel>Required
SC selector
configFindConfig<SalesChannel>Required
find config

Default: {}

Returns

PromisePromise<SalesChannel>Required
a single SC matching the query or throws

retrieve

Retrieve a SalesChannel by id

Parameters

salesChannelIdstringRequired
id of the channel to retrieve
configFindConfig<SalesChannel>Required
SC config This feature is under development and may change in the future. To use this feature please enable the corresponding feature flag in your medusa backend project.

Default: {}

Returns

PromisePromise<SalesChannel>Required
a sales channel

retrieveByName

Find a sales channel by name.

Parameters

namestringRequired
of the sales channel
configFindConfig<SalesChannel>Required
find config

Default: {}

Returns

PromisePromise<unknown>Required
a sales channel with matching name

listAndCount

Lists sales channels based on the provided parameters and include the count of sales channels that match the query.

Parameters

selectorQuerySelector<SalesChannel>Required
configFindConfig<SalesChannel>Required

Returns

PromisePromise<[SalesChannel[], number]>Required
an array containing the sales channels as the first element and the total count of sales channels that matches the query as the second element.

list

Lists sales channels based on the provided parameters.

Parameters

selectorQuerySelector<SalesChannel>Required
configFindConfig<SalesChannel>Required

Returns

PromisePromise<SalesChannel[]>Required
an array containing the sales channels

create

Creates a SalesChannel

This feature is under development and may change in the future. To use this feature please enable the corresponding feature flag in your medusa backend project.

Parameters

dataCreateSalesChannelInputRequired

Returns

PromisePromise<SalesChannel>Required
the created channel

update

Parameters

salesChannelIdstringRequired
dataPartial<CreateSalesChannelInput>Required

Returns

PromisePromise<SalesChannel>Required

delete

Deletes a sales channel from This feature is under development and may change in the future. To use this feature please enable the corresponding feature flag in your medusa backend project.

Parameters

salesChannelIdstringRequired
the id of the sales channel to delete

Returns

PromisePromise<void>Required
Deletes a sales channel from This feature is under development and may change in the future. To use this feature please enable the corresponding feature flag in your medusa backend project.

createDefault

Creates a default sales channel, if this does not already exist.

Returns

PromisePromise<SalesChannel>Required
the sales channel

retrieveDefault

Retrieves the default sales channel.

Returns

PromisePromise<SalesChannel>Required
the sales channel

listProductIdsBySalesChannelIds

List all product ids that belongs to the sales channels ids

Parameters

salesChannelIdsstring | string[]Required

Returns

PromisePromise<object>Required
List all product ids that belongs to the sales channels ids

removeProducts

Remove a batch of product from a sales channel

Parameters

salesChannelIdstringRequired
The id of the sales channel on which to remove the products
productIdsstring[]Required
The products ids to remove from the sales channel

Returns

PromisePromise<SalesChannel>Required
the sales channel on which the products have been removed

addProducts

Add a batch of product to a sales channel

Parameters

salesChannelIdstringRequired
The id of the sales channel on which to add the products
productIdsstring[]Required
The products ids to attach to the sales channel

Returns

PromisePromise<SalesChannel>Required
the sales channel on which the products have been added
Was this section helpful?