Hello
I Need to there is any option that we can pass product’s into REST API product api that we did not want that products id’s in “admin/api/2022-04/products.json” in this api e.g
We did not want product id 75825896,48589658,4785996 that we can pass these ids into “admin/api/2022-04/products.json” api and did not return these product’s ids information
I was able to filter products by ID on my test store using a query like this:
query excludeFilter {
products(
first: 10
query: "NOT id:'7215955836950' AND NOT id:'7215955804182' AND NOT id'7216003186710"
) {
edges {
node {
id
title
}
}
}
}
I have a similar case, but I want those Ids to be a list of ids to be excluded, and this list of ids to be passed as a variable. Could please advise if that available ? I tried your above query converted to a hard coded list and it doesn’t work like that
query:“NOT id: [‘44024516509903’, ‘44024516477135’]”
I appreciate your help, Thanks.
While you can pass a variable for the filter query, at this time it does not accept lists of ids in an array or other data structure as it’s input. The input for the query filter must be a string as described above.
However as you can pass the string through a variable, you should be able to programatically construct the strings to include the ids you wish, with your apps logic, before making the API call.
While we can’t help exactly with coding your app to programatically generate the strings to pass, we can provide you with an example of what passing an already generated string will look like in GraphQL.