SalesChannelService
internal.internal.SalesChannelService
Properties
__configModule__Record<string, unknown>__container__anyRequired__moduleDeclaration__Record<string, unknown>manager_EntityManagerRequiredsalesChannelRepository_Repository<SalesChannel> & { addProducts: Method addProducts ; getFreeTextSearchResultsAndCount: Method getFreeTextSearchResultsAndCount ; listProductIdsBySalesChannelIds: Method listProductIdsBySalesChannelIds ; removeProducts: Method removeProducts }RequiredtransactionManager_undefined | EntityManagerRequiredEventsobjectRequiredEvents.CREATEDstringRequiredEvents.DELETEDstringRequiredEvents.UPDATEDstringRequiredAccessors
activeManager_
Protected get activeManager_(): EntityManager
Returns
EntityManager
EntityManagerEntityManagerRequiredInherited from
TransactionBaseService.activeManager_
Methods
addProducts
addProducts(salesChannelId, productIds): Promise<SalesChannel>
Add a batch of product to a sales channel
Parameters
salesChannelIdstringRequiredproductIdsstring[]RequiredReturns
Promise<SalesChannel>
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.
TResultobjectRequiredTErrorobjectRequiredParameters
work(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandlerIsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail(error: TError) => Promise<void | TResult>Returns
Promise<TResult>
PromisePromise<TResult>RequiredInherited 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>
the created channel
createDefault
createDefault(): Promise<SalesChannel>
Creates a default sales channel, if this does not already exist.
Returns
Promise<SalesChannel>
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
salesChannelIdstringRequiredReturns
Promise<void>
PromisePromise<void>RequiredlistAndCount
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
configFindConfig<SalesChannel>Returns
Promise<[SalesChannel[], number]>
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[]RequiredReturns
Promise<{ [salesChannelId: string]: string[]; }>
PromisePromise<{ [salesChannelId: string]: string[]; }>Required
PromisePromise<{ [salesChannelId: string]: string[]; }>RequiredremoveProducts
removeProducts(salesChannelId, productIds): Promise<SalesChannel>
Remove a batch of product from a sales channel
Parameters
salesChannelIdstringRequiredproductIdsstring[]RequiredReturns
Promise<SalesChannel>
the sales channel on which the products have been removed
retrieve
retrieve(salesChannelId, config?): Promise<SalesChannel>
Retrieve a SalesChannel by id
Parameters
salesChannelIdstringRequiredconfigFindConfig<SalesChannel>Returns
Promise<SalesChannel>
a sales channel
retrieveByName
retrieveByName(name, config?): Promise<unknown>
Find a sales channel by name.
Parameters
namestringRequiredconfigFindConfig<SalesChannel>Returns
Promise<unknown>
PromisePromise<unknown>Requireda sales channel with matching name
PromisePromise<unknown>RequiredretrieveDefault
retrieveDefault(): Promise<SalesChannel>
Retrieves the default sales channel.
Returns
Promise<SalesChannel>
the sales channel
retrieve_
Protected retrieve_(selector, config?): Promise<SalesChannel>
A generic retrieve used to find a sales channel by different attributes.
Parameters
configFindConfig<SalesChannel>Returns
Promise<SalesChannel>
a single SC matching the query or throws
shouldRetryTransaction_
Protected shouldRetryTransaction_(err): boolean
Parameters
errRecord<string, unknown> | { code: string }RequiredReturns
boolean
booleanbooleanInherited from
TransactionBaseService.shouldRetryTransaction_
update
update(salesChannelId, data): Promise<SalesChannel>
Parameters
salesChannelIdstringRequiredReturns
Promise<SalesChannel>
withTransaction
withTransaction(transactionManager?): SalesChannelService
Parameters
transactionManagerEntityManager