upsertSalesChannels - Sales Channel Module Reference

This documentation provides a reference to the upsertSalesChannels method. This belongs to the Sales Channel Module.

NoteYou should only use this methods when implementing complex customizations. For common cases, check out available workflows instead.

upsertSalesChannels(data, sharedContext?): Promise<SalesChannelDTO>#

This method updates or creates a sales channel if it doesn't exist.

Example#

Code
1const salesChannel = await salesChannelModuleService.upsertSalesChannels({2  name: "B2B",3})

Parameters#

The attributes in the sales channel to be created or updated.
sharedContextContextOptional
A context used to share resources, such as transaction manager, between the application and the module.

Returns#

PromisePromise<SalesChannelDTO>
The created or updated sales channel.

upsertSalesChannels(data, sharedContext?): Promise<SalesChannelDTO[]>#

This method updates or creates sales channels if they don't exist.

Example#

Code
1const salesChannels = await salesChannelModuleService.upsertSalesChannels([2  {3    name: "B2B",4  },5  {6    id: "sc_123",7    description: "Sales channel for B2B customers",8  },9])

Parameters#

The attributes in the sales channels to be created or updated.
sharedContextContextOptional
A context used to share resources, such as transaction manager, between the application and the module.

Returns#

PromisePromise<SalesChannelDTO[]>
The created or updated sales channels.
Was this page helpful?
Ask Anything
FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break