collection.products only returning first 50 products

Highlighted
New Member
6 0 0

I am trying to loop through all products in a collection (regardless of current filtering or pagination) - ALL products of the collection. I'm trying to get a count of how many times each tag is used, so that when I output the tags, I can show a number next to it, like:

[] Blue (12) 
[] Black (9)
[] Red (2)

Showing that there are 12 products with the tag blue, etc. However, the counts I'm getting are wrong, and it seems to be because collection.products is not giving me all products; only the first 50. Is there a way around this?

This is the loop I'm using:

 

                  {% assign tag_use_count = 0 %}
                  {% for product in collection.products %}
                    {% for tag in product.tags %}
                      {% if tag == custom_tag %}
                        {% assign tag_use_count = tag_use_count | plus: 1 %}
                      {% endif %}
                    {% endfor %}
                  {% endfor %}

 

 

0 Likes
Highlighted
New Member
6 0 0

Anyone have any feedback about this, or workarounds I could consider?

0 Likes
Highlighted
Astronaut
1083 178 213

Hello,

This is standard behavior. Please refer to this thread, you may find an answer for your situation in there. 

Let me know how it goes for you.

Kind regards,
Diego

◦ Problem Solved? ✔️ Please click on Accept as Solution and like.
◦ Hire me! Recommended by 25+ customers on Facebook. Click here to read their reviews.
◦ Contact me at: diego.boarutto.fortes@gmail.com
0 Likes