SalesChannelService
Constructors
constructor
new SalesChannelService(«destructured»
)
Parameters
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 | EntityManagerRequiredEvents
objectRequiredEvents.CREATED
stringRequiredDefault: "sales_channel.created"
Events.DELETED
stringRequiredDefault: "sales_channel.deleted"
Events.UPDATED
stringRequiredDefault: "sales_channel.updated"
Accessors
activeManager_
Protected
get
activeManager_(): EntityManager
Returns
EntityManager
EntityManager
EntityManagerRequiredMethods
addProducts
addProducts(salesChannelId
, productIds
): Promise
<SalesChannel
>
Add a batch of product to a sales channel
Parameters
salesChannelId
stringRequiredproductIds
string[]RequiredReturns
Promise
<SalesChannel
>
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.
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Returns
Promise
<TResult
>
Promise
Promise<TResult>Requiredcreate
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
>
createDefault
createDefault(): Promise
<SalesChannel
>
Creates a default sales channel, if this does not already exist.
Returns
Promise
<SalesChannel
>
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
salesChannelId
stringRequiredReturns
Promise
<void
>
Promise
Promise<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
Returns
Promise
<[SalesChannel
[], number
]>
listProductIdsBySalesChannelIds
listProductIdsBySalesChannelIds(salesChannelIds
): Promise
<{ [salesChannelId: string]
: string
[]; }>
List all product ids that belongs to the sales channels ids
Parameters
salesChannelIds
string | string[]RequiredReturns
Promise
<{ [salesChannelId: string]
: string
[]; }>
Promise
Promise<{ [salesChannelId: string]: string[]; }>RequiredremoveProducts
removeProducts(salesChannelId
, productIds
): Promise
<SalesChannel
>
Remove a batch of product from a sales channel
Parameters
salesChannelId
stringRequiredproductIds
string[]RequiredReturns
Promise
<SalesChannel
>
retrieve
retrieve(salesChannelId
, config?
): Promise
<SalesChannel
>
Retrieve a SalesChannel by id
Parameters
salesChannelId
stringRequiredDefault: {}
Returns
Promise
<SalesChannel
>
retrieveByName
retrieveByName(name
, config?
): Promise
<unknown
>
Find a sales channel by name.
Parameters
name
stringRequiredDefault: {}
Returns
Promise
<unknown
>
Promise
Promise<unknown>RequiredretrieveDefault
retrieveDefault(): Promise
<SalesChannel
>
Retrieves the default sales channel.
Returns
Promise
<SalesChannel
>
retrieve_
Protected
retrieve_(selector
, config?
): Promise
<SalesChannel
>
A generic retrieve used to find a sales channel by different attributes.
Parameters
Default: {}
Returns
Promise
<SalesChannel
>
shouldRetryTransaction_
Protected
shouldRetryTransaction_(err
): boolean
Parameters
err
Record<string, unknown> | { code: string }RequiredReturns
boolean
boolean
booleanupdate
update(salesChannelId
, data
): Promise
<SalesChannel
>
Parameters
salesChannelId
stringRequiredReturns
Promise
<SalesChannel
>
withTransaction
withTransaction(transactionManager?
): SalesChannelService
Parameters
transactionManager
EntityManager