I have a product metafield defined as a list of metaobject references intended to be used within a smart collection.
Smart collections allows for defining conditions as follows:
-
Product fields:[Title, Type, Category, Vendor, Tag, Price, Compare-at price, Weight, Inventory stock, Variant’s title]
&
Metafields:[metafield-a, metafield-b, …] -
[is equal to, is not equal to, starts with, ends with, contains does not contain]
-
[value]
where the first bullet point corresponds to the field you want to filter by, the second bullet point is the comparison rules (relevant/available for the selected field), and the third bullet point is the value we define.
For my configuration I am doing:
-
[Metafield:Foo] where “Foo” is my metafield defined as a list of metaobject references to a “Bar” metaobject
-
[is equal to] it appears that for metaobject references (single or list), “is equal to“ is the only option
-
[A] my metaobject entry for the “Bar“ metaobject which has entries [A, B, C]
On my product, I’ve set 2 “Bar“ metaobject entries, “A” & “B” as values for the “Foo“ metafield.
Given that my product has 2 entries, and I can only select 1 in the smart collection and am limited to “is equal to“ I would expect my product not to be added to the collection, but it does get added.
Personally, I like the fact that this works, but it’s kind of confusing reading “Foo | is equal to | A“ in the smart collection, given that on my product Foo=A,B
The main thing here is I want to make sure that this is expected behavior and not some sort of oversight that will be fixed to exclusively match Foo=single-value.
It is my understanding that the ‘contains‘ rule along with some other ones are for string value types only and probably couldn’t be used for metaobject references (unless maybe we could map the value of the smart collection rule to whatever field we are using as the display name, if defined, for the metaobject entries).
—————————————————————————————————————————
Aside from that, I actually went down this rabbit hole because initially I wanted to do the following:
[Metafield:Foo] [Not empty and exists] but this is just not doable in general for smart collections it seems.
The goal was to define a metafield as a date/time value, and add products to a collection if the product had a value set for the metafield regardless of the value itself, then I would use this date value within Shopify Flow.
That way I’d only need one metafield definition to achieve two things
- Add product to collection via smart collection rules set to detect whether a metafield value is set (not match a specific value)
- Use the data from that same metafield without having to define a separate metafield/metaobject.
Will these types of conditions ever be implemented for smart collections the way they are in Shopify Flow?