Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: GraphQL API: ProductCreate does not publish product to channel

Solved

GraphQL API: ProductCreate does not publish product to channel

garyrgilbert
Shopify Partner
431 41 186

 

When creating a product using the ProductCreate graphQL mutation the product does not get added to the sales channels even though the product status is set to ACTIVE.

 

From the documentation:

garyrgilbert_0-1650967221796.png

My understanding of the above text is that if the product status is active during creation of the product it should automatically be added to all channels.

 

Requiring an additional request to publish the product after-the-fact is counter-intuitive and increases network load, in addition to having a different result as with the rest API which does in fact publish the product to all channels when the status is active.

 

Any help on confirming that this is a bug?

 

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
Accepted Solution (1)
lizk
Shopify Staff
246 58 78

This is an accepted solution.

Hi, 

Sorry for not being explicit it appeared you had it correct.

1) You can currently publish a product to the online store via the deprecated 'published' field on the productCreate mutation
2) You can publish to any sales channel with the PublishablePublish mutation.

To learn more visit the Shopify Help Center or the Community Blog.

View solution in original post

Replies 16 (16)

lizk
Shopify Staff
246 58 78

Hi there! 

tldr; is for the GraphQL API, this is the intended functionality, you will have to make two mutations.

So when Product Status was released, it was intended that to decouple the status from the publishing of products to sales channels. 
Decoupling publishing from status allows a lot more flexibility for merchants when they are creating their products. 

You will also notice with the GraphQL API creating a product and publishing a product have two different scopes required. 

I agree that the current description of the Active status is misleading, so you should see updated docs for that coming soon. 

To learn more visit the Shopify Help Center or the Community Blog.

garyrgilbert
Shopify Partner
431 41 186

Hi Lizk,

 

thanks for the reply and the explanation. I understand wanting to decouple and quite often it makes sense, but also there are times where it's simply overcomplicating, which I believe is what your team are doing in this case. Requiring two http requests to perform an operation where only one is required for the rest api is a step backwards.  The now deprecated options in the previous version of the mutation make more sense as well.  Having the option create a product and publish it to all available channels at the same time.  The way the .mutation is now requires also knowing th id's of the channels you wish to publish the product. So if we haven't stored this previously what would would take a single http request using the rest api would take a minimum of 3 http requests with graphQL. Furthermore the now deprecated options are replaced with publishablepublish which apparently is only available for plus merchants or are we supposed to use productPublish..oh wait thats also only available for plus merchants.. so what mutation are we supposed to use then to publish the newly created product that's active but actually not?

 

So at the end of the day I can create a product, via graphql, but can't publish it to the available channels on the merchants shop? Or am I missing something, or has the dev team dropped the ball along the way trying to "decouple" everything? I guess I will stick with the REST API until the growing pains with graphql are over.  Granted it does make some operations easier but others like this are in my opinion just not really thought through.

 

Regards

Gary

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
lizk
Shopify Staff
246 58 78

This is all really valuable feedback, that I can forward on to the the team! Thanks

To learn more visit the Shopify Help Center or the Community Blog.

garyrgilbert
Shopify Partner
431 41 186

Hi Lizk,

 

Unfortunately, I didnt get any feedback to the question of how I publish a product via graphql.

 

Cheers,

 

Gary

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
lizk
Shopify Staff
246 58 78

This is an accepted solution.

Hi, 

Sorry for not being explicit it appeared you had it correct.

1) You can currently publish a product to the online store via the deprecated 'published' field on the productCreate mutation
2) You can publish to any sales channel with the PublishablePublish mutation.

To learn more visit the Shopify Help Center or the Community Blog.

stefaan
Shopify Partner
3 0 2

Hello, I have a very similar problem. When I create and publish a product using ShopifySharp c#/.NET library, it gets only published to Online Store channel, but not the Buy Button channel.

Is there a way to do it in ShopifySharp (if anyone's aware of this) to publish to all channels, and/or is there an alternative in Rest API (I couldn't find anything similar to PublishablePublish in Rest API)? We don't use GraphQL...

Thanks! S.

emiller
Shopify Partner
19 0 10

Is there a way to do this with the REST Admin API?

garyrgilbert
Shopify Partner
431 41 186

Yes if you use the standard product create rest api endpoint the product will automatically be added to all channels.

 

https://shopify.dev/api/admin-rest/2021-10/resources/product#post-products

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
emiller
Shopify Partner
19 0 10

Hmmm, that's not the behavior that I am seeing. I was able to publish a product, but it was only on the "Online Store" sales channel. 

garyrgilbert
Shopify Partner
431 41 186

With the rest API? If so then the behavior has changed, but I don't see any indication of that in the change log. We have an app, early 2021, where we use the rest api to create a product, and it added it to all sales channels. 

 

I just tested this and can confirm that it only now adds it to the online store, and there does not appear to be a way to publish the product to all sales channels via the product rest api!

 

@lizk can you please confirm that there is no way to add a product to a sales channel via the rest api?

 

 

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
emiller
Shopify Partner
19 0 10

Yes I'm using the `/admin/api/2021-10/products.json` endpoint.

 

emiller
Shopify Partner
19 0 10

So I tried this again. I thought that maybe I needed to provide some additional fields on the product data, so I tried it with data that looked like this:

 

```

{
"product": {
"body_html": "This is a test product.",
"title": "Test Product - Single",
"status": "active",
"published_scope": "global"
}
}

```

I hadn't provided the `status` and `published_scope` field before. Still, this made no difference. The product was only published to the "Online Store" sale channel.

ronald_g
Explorer
80 2 16

Hi @lizk 

 

Regarding your note that "You can publish to any sales channel with the PublishablePublish mutation." However, the shopify.dev documentation says that this mutation "requires `write_publications` access scope, but this scope is currently available only to private apps installed on Shopify Plus stores." Does this mean that public apps cannot use this mutation to publish to channels? If not, how can we publish to channels on product update?

 

2022-07-18_12-00-52.png

APDEV
Shopify Partner
5 0 1

Why the PublishablePublish mutation cannot be performed into a bulkOperationRunMutation?
Seems that this action cannot be perfomed in bulk: https://shopify.dev/api/usage/bulk-operations/imports

Once we cannot publish anymore with productCreate/Update (deprecated) it should be useful to run this mutation in bulk

dblack
Shopify Partner
7 0 5

So over a year later and the answer is still to use deprecated fields? Seems like a bad idea to deprecate a feature when it is the only way to achieve something.

Ajay_399
Shopify Partner
11 0 11

Midway through 2024, and this issue still persists