How to publish a Product to All Sales Channels when creating a new Product through REST API

Solved

How to publish a Product to All Sales Channels when creating a new Product through REST API

hassanashas
Shopify Partner
10 0 1

Hello,

 

I am working on creating a product using a REST API and have successfully managed to handle most aspects of the process. However, I'm currently facing a challenge with publishing the newly created product across all Sales Channels. Despite setting the "published_scope" to "global," the product is not being published to all the channels as expected. I have to create hundreds of products through the API so can't set this manually. 

 

Could anyone help on this matter? Specifically, I need help on determining the correct parameter to use when calling the REST API for new product creation, which would ensure the product is published to all sales channels. Any practical examples would be grealty appreciated.

 

Thank you.

Accepted Solution (1)

SBD_
Shopify Staff
1829 271 414

This is an accepted solution.

Hey @hassanashas 

 

I believe the only way to publish to channels other than the Online Store is to use the GraphQL publishablePublish mutation.

Scott | Developer Advocate @ Shopify 

View solution in original post

Replies 4 (4)

SBD_
Shopify Staff
1829 271 414

This is an accepted solution.

Hey @hassanashas 

 

I believe the only way to publish to channels other than the Online Store is to use the GraphQL publishablePublish mutation.

Scott | Developer Advocate @ Shopify 

hassanashas
Shopify Partner
10 0 1

Is there no option to do it using REST API?
If I am to use this GraphQL, then I will have to make additional calls just to update these channels for all of my newly created products.

SBD_
Shopify Staff
1829 271 414

Yeah it's not ideal. You can do it with a single call if you create the product using GraphQL, but this `publications` field is deprecated and also replaced by a publishablePublish call.

 

`published_scope` on the REST API refers to web/POS.

Scott | Developer Advocate @ Shopify 

hassanashas
Shopify Partner
10 0 1

Yeah, would really like some option to do the same in REST API, or they should at least provide an update to the deprecated option.

Anyway, I ended up calling REST APIs to create the products and then calling GraphQL in a separate call to update the publications. This will definitely impact the performance of my program, but I guess it is what it is.

 

Thanks a lot for your help!