We should be able to exclude products with the collection by using the negation filters (“-collection_id” or “NOT collection_id”). However, this causes extremely unexpected behavior where it returns the same products multiple times, and the products still are in the collection.
We should be able to mix and match this query with other fields. The way the documentation is worded sounds like it’s only supported to match along with specific other fields, which should be documented more clearly if that’s true. But this limitation should be removed if possible. But I’m seeing issues even when filtering along with supported fields. For example, adding the title field it only matches if the title exactly matches. And if you separate the two filters with “OR” it doesn’t match anything. Also matching multiple collections doesn’t seem to work.
Upon further testing, it seems connectives are not supported when using “collection_id”, as adding “AND” or “OR” matches nothing, but taking away the “AND” allows multiple fields to be included. But even that only works in some cases.
Overall it behaves very strangely and doesn’t follow the other rules of the Shopify query syntax, which is very disappointing. It basically only works correctly if you only want to filter by a single collection and nothing else.
I have a work around this by adding the collection handle as a value in the tags so I add a tag with the value collection_{handle} so my query now will be
I’ve just run into this as well. Apparently for ID fields or numerical fields we can only use the standard comparators
:: equality
:<: less-than
:>: greater-than
:<=: less-than-or-equal-to
:>=: greater-than-or-equal-to
but there is no way to use a negation, apparently negation only works for text fields.
“warnings”: [
{
“field”: “id”,
“message”: “Expected field to be a positive integer or UUID, received -9833428025658.”
}
]
It would be super helpful to be able to create a query and like tag_not have the ability to say "“give me all products not in the “sale” collection”. This would be a huge help Instead of having the merchant first create a “not sale” collection.
I am noticing that while using the Product GraphQL APIs, the AND filter isn’t working as expected (or so I think?). In the default dataset for dev stores, there’s a product called The Collection Snowboard: Liquid Success and it belongs to Automated Collection and Hydrogen collections. When I am building the query variables for looking up the product WITHIN a collection like this:
{ “query”: “(title:liquid) AND (collection_id:one_of_the_collection_ids_here)” }
It’s returning me no products!
Clearly if I remove either the title or collection filters, I am getting the product/products so what am I missing here? Am I making a mistake understanding the purpose of AND?
If there are thousands of products under multiple collections and I want to drill down and filter out products within that collection, how would I achieve that? The OR condition is working as expected.