How to filter Admin API products by (current) publication

Solved

How to filter Admin API products by (current) publication

LeonLinhart
Shopify Partner
2 1 0

Hi, ideally I would like to query only for products published to the current (i.e. the app's) publication. I've stumbled across a similar older question that suggested using the "product_status" filter with a value of "[channel_name]:[hidden|visible]". However, not only would require separately fetching the publication's ID, it does not appear to work anymore (as outlined in the linked thread).

 

Is there an alternative available? My current solution would be to request the "publishedOnCurrentPublication" field and filter afterward using that. This generates additional traffic though that I would like to avoid if possible.

 

Regards
Leon Linhart

Accepted Solution (1)

LeonLinhart
Shopify Partner
2 1 0

This is an accepted solution.

It turned out that the syntax is still valid and this is possible even with GraphQL in my use-case. My specific issue was missing single quotes around the value for the "published_status" parameter. For some reason, Shopify didn't raise any error even when it didn't parse the query as expected.

 

Credit goes to Brdata's response here. 



@brdata wrote:

@HerculesApps 

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'"

 


View solution in original post

Reply 1 (1)

LeonLinhart
Shopify Partner
2 1 0

This is an accepted solution.

It turned out that the syntax is still valid and this is possible even with GraphQL in my use-case. My specific issue was missing single quotes around the value for the "published_status" parameter. For some reason, Shopify didn't raise any error even when it didn't parse the query as expected.

 

Credit goes to Brdata's response here. 



@brdata wrote:

@HerculesApps 

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'"