Collection Pages showing Random numbers of Products

Collection Pages showing Random numbers of Products

Bluflare
Shopify Partner
9 1 3

Hi all, 

 

I'm having issues with my collection pages. I'm using the Empire theme by Pixel Union (I have reached out to them).

 

The issue is the collection pages are showing random numbers of products even though the Products per Page setting is set to 36. For example if you look at how this collection is paginated it's showing some pages with 36 products, others with very few - https://www.andrewmorrisgolf.com/collections/stand-bags?page=3&grid_list=grid-view

 

I have changed some of the default code below so it should exclude products of a certain type and out of stock products, but don't see why this would cause the issues. I tested changing collection settings in shopify admin to exclude this product type and only show products with inventory stock of greater than 0, which did resolve the issue for this collection - https://www.andrewmorrisgolf.com/collections/golf-balls. However I Have so many collections I don't want to have to do this manually for all. 

 

The code I feel might be responsible is below.  I can provide the entire static-collection.liquid file if required. 


Thanks in advance, Roo.

 

      {% if collection.products.size > 0 %}
  <ul
  class="
    productgrid--items
    products-per-row-{{- section.settings.products_per_row -}}
  "
  data-html="productgrid-items"
  data-productgrid-items
>
  {% for product in collection.products %}
    {% if product.type == 'mws_apo_generated' %}
      {% continue %}
    {% endif %}
    
    {% assign product_in_stock = false %}
    
    {% for variant in product.variants %}
      {% if variant.inventory_quantity > 0 %}
        {% assign product_in_stock = true %}
        {% break %}
      {% endif %}
    {% endfor %}
    
    {% if product_in_stock %}
      {%- render 'product-grid-item', product: product -%}
    {% endif %}
  {% endfor %}
</ul>

 

Reply 1 (1)

Bluflare
Shopify Partner
9 1 3

Further to the above, I think the issue may be related to pagination and when the filtering or products occurs possibly. As in, the conditions I have to exclude particular products may not be happening prior to product-grid-item being rendered, not 100% sure but any insight into this would be great. It's like, the product grid is being rendered then just not condensing the products to the correct number of pages and filling all the product tile positions on the product grid.