Find Group in Metaobject Containing Specific Product ID

Hi guys!
I have a metaobjects called ⁠product_group that contains arrays of product IDs. The metaobjects returns data in this format:

[
  {
    "products": [
      "gid://shopify/Product/7965101949181",
      "gid://shopify/Product/8883750142279"
    ]
  },
  {
    "products": [
      "gid://shopify/Product/8947651903815",
      "gid://shopify/Product/8947651936583"
    ]
  }
]

What I’m trying to achieve is to display other products from the same group on a product page.

For eg:

Since I have nearly 200+ metaobject entries, some matches cannot be found due to the 50-item listing limit.

Would something like this be possible in Liquid?
⁠{{ shop.metaobjects.product_group.values | find: "products", current_product_id }}

I’m looking for an efficient way to find through these metaobject entries and solve this issue. Any built-in Liquid filters or alternative approaches would be really helpful.

Any guidance or best practices would be greatly appreciated.

Thank you!

You can paginate through metaobject lists. Refer to the paginate documentation here: https://shopify.dev/docs/api/liquid/tags/paginate

I also found this thread helpful with a bunch of examples: Re: Using Metaobjects. Cannot access more than 50 entries in theme. - Shopify Community

1 Like