Skip to main content
Skip to main content

SalesChannelService

Properties

__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
eventBusService_EventBusServiceRequired
manager_EntityManagerRequired
salesChannelRepository_Repository<SalesChannel> & { addProducts: Method addProducts ; getFreeTextSearchResultsAndCount: Method getFreeTextSearchResultsAndCount ; listProductIdsBySalesChannelIds: Method listProductIdsBySalesChannelIds ; removeProducts: Method removeProducts }Required
storeService_StoreServiceRequired
transactionManager_undefined | EntityManagerRequired
EventsobjectRequired
Events.CREATEDstringRequired
Events.DELETEDstringRequired
Events.UPDATEDstringRequired

Accessors

activeManager_

Inherited from

TransactionBaseService.activeManager_

Methods

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

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.

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

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
Returns
PromisePromise<SalesChannel>Required
the created channel

createDefault

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

Returns
PromisePromise<SalesChannel>Required
the sales channel

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

listAndCount

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

Parameters
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.

listProductIdsBySalesChannelIds

List all product ids that belongs to the sales channels ids

Parameters
salesChannelIdsstring | string[]Required
Returns
PromisePromise<{ [salesChannelId: string]: string[]; }>Required

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

retrieve

Retrieve a SalesChannel by id

Parameters
salesChannelIdstringRequired
id of the channel to retrieve
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.
Returns
PromisePromise<SalesChannel>Required
a sales channel

retrieveByName

Find a sales channel by name.

Parameters
namestringRequired
of the sales channel
find config
Returns
PromisePromise<unknown>Required
a sales channel with matching name

retrieveDefault

Retrieves the default sales channel.

Returns
PromisePromise<SalesChannel>Required
the sales channel

retrieve_

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

Parameters
selectorSelector<SalesChannel>Required
SC selector
find config
Returns
PromisePromise<SalesChannel>Required
a single SC matching the query or throws

shouldRetryTransaction_

Parameters
errRecord<string, unknown> | { code: string }Required
Returns
booleanboolean

update

Parameters
salesChannelIdstringRequired
Returns
PromisePromise<SalesChannel>Required

withTransaction

Parameters
transactionManagerEntityManager
Returns
SalesChannelServiceSalesChannelServiceRequired
Was this section helpful?