I have the following query:
query GetProductsTagged {
products(query: "status:ACTIVE,tag:Trainers", first: 200) {
nodes {
id
title
herring_shoe_id: metafield(namespace: "custom", key: "herring_shoe_id") {
value
}
}
pageInfo {
startCursor
endCursor
}
}
}
I have 1351 products tagged with the tag ānot-trainersā, which is a utility tag we use to help craft collections of products that we donāt want to see trainers in. This is necessary because of Shopifyās limited smart collection functionality: we canāt specify a NOT condition for tags in the rules, so this is the workaround we came up with.
I have zero products tagged with the tag āTrainersā.
The above query, which I will remind us all has the query āstatus:ACTIVE,tag:Trainersā returnsā¦
Yes, you guessed it, it returns the 1351 products with the ānot-trainersā tag.
So then I thought, OK, Shopify must do this search based on the tag term being like a tag, so I repeated the query with the term ārainerā:
products(query: āstatus:ACTIVE,tag:rainerā, first: 200) {
ā¦and got zero results.
When I wrap the tag term in quotes, like some other examples in the documentation for the products query, like this: products(query: āstatus:ACTIVE,tag:āTrainersāā, first: 200) {
The results are the same. 1351 for āTrainersā, again returning the ānot-trainersā products, and zero for ārainerā.
If anyone can shed some light on what is going on here, that would be amazing.
In the meantime I now have to rewrite this code to just get all products, get each productās tags, and then check to see if the tag Iām interested in is one of them. This is bonkers.
Many thanks,
G
PS - wait, did I just do a (minor) inadvertant injection attack?
Edit: noticed the same problem with the productsCount query:
query {
productsCount(query: "status:ACTIVE,tag:Trainers",limit: null) {
count
}
}
returns a count of 1351.