Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Problem: I want to pull a list of products and use the normal snippets built into my code for paginating through them. When I attempt to do so, I am shown that paginating does not work with the data I have pulled.
Use case: I want to search a list of products that contain an ingredient and display them in a section similar to how I display related products at the bottom of a page via collections.
Background info: Our ingredients exist as metaobjects. Our products each have a metafield called ingredients, that contain a list of the corresponding ingredient metaobjects. I have enabled Shopify's new feature that allows us to have a metaobject template, so every ingredient has its own page now. This is great! However, I want to display all of the products that contain the ingredient on each of the ingredient pages. This should be easy, right? Unless I am missing something, this is not easily possible.
In a perfect world, Shopify should allow us to pull the products directly from the metaobject entries that have been referenced by those products. When I view each metaobject entry, I can in fact see the products listed and it says "Referenced by" and lists the products where that metaobject was referenced. However, at this time, Shopify does not allow us to use this data directly.
In addition, Shopify also does not allow us to use the metaobject data to make an automated collection for each ingredient. So that functionality won't work either.
Possible Solutions: The only options that I can think of are the following:
1. One by one, go to every single metaobject entry and add the products that contain that ingredient as a new field. This functionally should work, but requires double the work that has already been invested. Yes, it's probably possible using something like Matrixify and compiling the data and then doing a large import. But this is not easily accomplished, and would cost money for a larger plan, or at the very least require a lot of work to compile the data properly and multiple imports. And then still has the problem of duplicating the data, which should always be avoided: meaning that if the ingredients ever change, I will then have to change the data in two places (on the products where I have already linked the metaobjects, and on each metaobject itself). This seems like an oversight that it doesn't already exist...but I digress.
2. My preferred solution is to pull a list of the products, search their ingredient metafield to see if the current metaobject page is a match to any of them, and then loop through the results, and display those products. This seems like it should work, and I think I am close to achieving this. However, when I attempt to use my existing snippets/sections to display the results, I am seeing an error that the results are not paginateable. Upon further research, I now understand that Shopify uses the paginate function specific to collections. Which brings me here. What are my options to achieve this?
Please Help! I have already watched multiple videos and read all the relevant info I can find. I am happy to share code or whatever additional info is needed. And if you have an alternative solution that solves the same problem, please let me know. Any help would be much appreciated!
For relating ingredient pages to products this is the same method as if metaobjects didn't exist.
Just use tags, tag products with the ingredients make tag based collections for those ingredients tagged products.
If the ingredients are in the product descriptions use excel|google-sheet and formulas to populate the ingredient tags quickly via product export and import.
Metaobjects allow some new behavior but the reality is all merchant meta data is a third class data-citizen on the platform. In a better reality merchants could replicate any data structure on shopify through metaobjects as they need it along with custom fields that behave natively i.e. product with expiration dates, products with more than 100 variants* ,more than 3 options etc etc.
So to use things like Metaobjects effectively for anything with more than one branch of conditions,data, or relations that requires investing in apps or building a custom data process for the businesses information architecture.
If you need to build custom automations see apps like mesa, or usemechanic to build custom processes without making your own apps.
*First thing I tried and was infuriating to find out how accessing things in metaobjects work by having to loop over everything or hardcoding exact paths.
Contact paull.newton+shopifyforum@gmail.com for the solutions you need
Save time & money ,Ask Questions The Smart Way
Problem Solved? ✔Accept and Like solutions to help future merchants
Answers powered by coffee Thank Paul with a ☕ Coffee for more answers or donate to eff.org
Hi Paul, I appreciate your input and information. I understand that the old way of accomplishing this involved the cumbersome process of tagging all products with ingredients and making specific collections. However, I specifically want to know how to accomplish this using metaobjects, since the example of ingredients is the exact use case that Shopify has been advertising as the benefit of metaobjects. And the products are all already tagged with a metafield pointing to each metaobject of their respective ingredients.
For example, in this product, in the ingredients metafield, I am able to easily reference the ingredient metaobjects, shown here:
And then when going to a particular ingredient metaobject, I can easily see that it is linked to the respective products, as shown here:
It seems silly and counterintuitive to me that there is not a way to now show those products on that metaobject page without ignoring the metaobject functionality completely and implementing a whole new method. Hope that makes sense.
Even if it is the case that Shopify does not allow us currently to pull the "referenced_by" data, I would at least think there is a way to cycle over the ingredient metafields and find the matches. Please let me know if you have any ideas.
Hey just wondering if you got a solution. I think the answer might be related to one of my problem which is:
To have the possibility of creating a product page that would just be there as a placeholder (with no variants nor add to cart, just with the medias), called 'Queen and King, which functionality is to have inside 2 (option to add more) dropdown menu or a button which when opened/clicked it will show inside of the dropdown menu or as a pop up if it’s a button, a collection page that I will insert; for instance the first dropdown menu (or button) will be called “Choose Queen” and when opened it will show the collection that I choose (which I will create to have only products with “Queen” written on), the second dropdown menu (or button) will have “Choose King” with the respective collection. The collection will need to perform just like I design it on the product template (so it will show the swatches and quick view options if they had them)
As per the dropdown menu option take this as reference: https://theoodie.com/products/customizeable-oodie-family-pack
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024