A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hi!
I've noticed from the Products search API https://shopify.dev/docs/admin-api/rest/reference/products/product#index-2020-07
That there are options to search by `published_status` and `status`. Are these two fields related? For example does `status=active` imply that `published_status=published` ?
If they are not the same:
Solved! Go to the solution
This is an accepted solution.
Hi @sengming,
I'd try to explain the difference between the the status
and published_status
fields of the Product resource, and hopefully I can clarify any confusion you have.
For the Rest API,
the status
field of a Product resource indicates the product status. Possible values are active, draft, or archived.
the published_status
of a Product resource indicates what channel the product is available on. Using the values published, unpublished, or any, the channel used is the online store. There is flexibility to select products from a specific channel also. You can use the following [channel_name]:[hidden|visible]
as the value (the value should be url encoded). For example finding all products published on the Buy Button channel would use /admin/api/2020-10/products.json?published_status=buy_button%3Avisible
(url encoded).
To answer your question about how to query for products that have an active status using GraphQL, see the example below
{
products(first:10, query: "status:active") {
edges {
node {
id
status
}
}
}
}
I hope this helps, and the differences between the status
and published_status
fields are clearer now.
Best,
Seth.
syf_ | Developer Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
This is an accepted solution.
Hi @sengming,
I'd try to explain the difference between the the status
and published_status
fields of the Product resource, and hopefully I can clarify any confusion you have.
For the Rest API,
the status
field of a Product resource indicates the product status. Possible values are active, draft, or archived.
the published_status
of a Product resource indicates what channel the product is available on. Using the values published, unpublished, or any, the channel used is the online store. There is flexibility to select products from a specific channel also. You can use the following [channel_name]:[hidden|visible]
as the value (the value should be url encoded). For example finding all products published on the Buy Button channel would use /admin/api/2020-10/products.json?published_status=buy_button%3Avisible
(url encoded).
To answer your question about how to query for products that have an active status using GraphQL, see the example below
{
products(first:10, query: "status:active") {
edges {
node {
id
status
}
}
}
}
I hope this helps, and the differences between the status
and published_status
fields are clearer now.
Best,
Seth.
syf_ | Developer Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
I am trying it using the 2020-10 API version and the status field doesn't seem to be supported. The documentation also doesn't show that it is supported.
Edited: Figured it out. I had an error in the syntax.
@syf_ Could you please document the query syntax for the
published_status
field as it pertains to specific sales channels? You mentioned the
[channel_name]:[hidden|visible]
syntax.... could you please add this to the official Shopify documentation?
Thanks.
Also @syf_ , if possible show how to use that syntax to query for visible to a *private app* which is acting as a sales channel (e.g. doesn't show up in the "Sales Channel" list in the main admin nav, but is on the list for publish/unpublish for products).
How does published_status works in a the GraphQL query search syntax?
I tried
query: "published_status:[channel-name]:visible"
And also tried
query: "published_status:[channel-name]=visible"
Hope someone can explain the right solution.
A bit late, but here's what worked for me.
You need to enclose the channel-name and visibility in quotes.
query: "published_status:'pos:visible' OR published_status:'online_store:hidden'"