In the Shopify admin, you can view and modify the publications for products that are in draft. The products aren’t actually published, but they will be once the product is active.
However, the API returns no publications for draft products. For example:
Returns 0 for the counts and an empty list for publications. After setting the status to active, it will have all the ones available that are shown in the admin.
I think it should match the behavior of the Shopify admin, or at least add a flag to the query so we can still fetch the publications that are ready to be published once the product is active. Otherwise, it causes a discrepancy with the admin and confuses merchants since we have to display the product with no publications in the app while it’s in draft.
The standard publication fields are designed to only return currently published resources, which is why you’re seeing empty results for draft products.
There are still a couple of ways to get the publication information you need for draft products.
First, you can use the unpublishedPublications field which returns all publications that the draft product is configured to publish to once it becomes active.
Second, you can use resourcePublicationsV2 with the onlyPublished: false parameter, which gives you the same publications plus additional metadata like isPublished status and publishDate.
Both approaches should get you close to what you see in the Shopify admin.
Thanks! I meant to check for a query parameter like that, but I guess I never did. I was under the impression unpublishedPublications included all possible publications that aren’t published, not necessarily the ones that are added when the product is in draft. But the onlyPublished: false query does exactly what I need since I want both!
Alright, now I have a similar issue, this time with the query filters for products.
It seems when using publication_ids:XXXXX in a product query filter, it only includes published publications. Is there a way to also include the unpublished ones?