Skip to main content
Skip to main content

SalesChannelService

internal.internal.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_

Protected get activeManager_(): EntityManager

Returns

EntityManager

EntityManagerEntityManagerRequired

Inherited from

TransactionBaseService.activeManager_

Methods

addProducts

addProducts(salesChannelId, productIds): Promise<SalesChannel>

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

Promise<SalesChannel>

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

atomicPhase_

Protected atomicPhase_<TResult, 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.

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

Promise<TResult>

PromisePromise<TResult>Required
the result of the transactional work

Inherited from

TransactionBaseService.atomicPhase_


create

create(data): Promise<SalesChannel>

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

Promise<SalesChannel>

PromisePromise<SalesChannel>Required
the created channel

createDefault

createDefault(): Promise<SalesChannel>

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

Returns

Promise<SalesChannel>

PromisePromise<SalesChannel>Required
the sales channel

delete

delete(salesChannelId): Promise<void>

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

Promise<void>

PromisePromise<void>Required

listAndCount

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

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

Parameters

Returns

Promise<[SalesChannel[], number]>

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

listProductIdsBySalesChannelIds(salesChannelIds): Promise<{ [salesChannelId: string]: string[]; }>

List all product ids that belongs to the sales channels ids

Parameters

salesChannelIdsstring | string[]Required

Returns

Promise<{ [salesChannelId: string]: string[]; }>

PromisePromise<{ [salesChannelId: string]: string[]; }>Required

removeProducts

removeProducts(salesChannelId, productIds): Promise<SalesChannel>

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

Promise<SalesChannel>

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

retrieve

retrieve(salesChannelId, config?): Promise<SalesChannel>

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

Promise<SalesChannel>

PromisePromise<SalesChannel>Required
a sales channel

retrieveByName

retrieveByName(name, config?): Promise<unknown>

Find a sales channel by name.

Parameters

namestringRequired
of the sales channel
find config

Returns

Promise<unknown>

PromisePromise<unknown>Required
a sales channel with matching name

retrieveDefault

retrieveDefault(): Promise<SalesChannel>

Retrieves the default sales channel.

Returns

Promise<SalesChannel>

PromisePromise<SalesChannel>Required
the sales channel

retrieve_

Protected retrieve_(selector, config?): Promise<SalesChannel>

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

Parameters

selectorSelector<SalesChannel>Required
SC selector
find config

Returns

Promise<SalesChannel>

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

shouldRetryTransaction_

Protected shouldRetryTransaction_(err): boolean

Parameters

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

Returns

boolean

booleanboolean

Inherited from

TransactionBaseService.shouldRetryTransaction_


update

update(salesChannelId, data): Promise<SalesChannel>

Parameters

salesChannelIdstringRequired

Returns

Promise<SalesChannel>

PromisePromise<SalesChannel>Required

withTransaction

withTransaction(transactionManager?): SalesChannelService

Parameters

transactionManagerEntityManager

Returns

SalesChannelService

SalesChannelServiceSalesChannelServiceRequired

Inherited from

TransactionBaseService.withTransaction

Was this section helpful?