Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
I need to access products in the collection.all.products array by a certain tag on a normal page template.
I can't put this into their own seperate collection they need to be accessed in the collection.all collection.
Is there any way i can do this via liquid??
I can use the where filter to return products with other attributes like the below code will return any product with the vendor 'Apple'.
{% assign current_products = collections.all.products | where: 'vendor', 'Apple' %} {% for product in current_products %} {{ product.vendor }} {% endfor %}
{% assign current_products = collections.all.products | where: 'tags', 'phone' %} {% for product in current_products %} {{ product.title }} {% endfor %}
Thanks
Solved! Go to the solution
This is an accepted solution.
No.
The where filter operates on the passed array based on a property of the individual items in that aray.
Not on objects, or an objects arrays
A resources tags have some convenience behaviors when working with them but they aren't a single property which of course leads to hopeful expectations they should be useful for something like the |where: filter.
Currently this is solved with either:
A specific collection setup with conditions based on the target tag.
Or if you can do this on the client side just fetch that tag filter collection url using a special template you use specifically for ajax or the section rendering api. Keeping in mind pagination.
/collections/collectionname/tagname
What you don't want to do is try to loop over all products in an ALL collection.
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
This is an accepted solution.
No.
The where filter operates on the passed array based on a property of the individual items in that aray.
Not on objects, or an objects arrays
A resources tags have some convenience behaviors when working with them but they aren't a single property which of course leads to hopeful expectations they should be useful for something like the |where: filter.
Currently this is solved with either:
A specific collection setup with conditions based on the target tag.
Or if you can do this on the client side just fetch that tag filter collection url using a special template you use specifically for ajax or the section rendering api. Keeping in mind pagination.
/collections/collectionname/tagname
What you don't want to do is try to loop over all products in an ALL collection.
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
Thanks @PaulNewton. Make perfect sense. Will test a few of the suggestions you noted.
Cheers!
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025