Does pagination include draft products?

Short description of issue

pagination includes draft products

Reproduction steps

{%liquid
if collection.products.size > 0
paginate collection.products by section.settings.products_number
if paginate.current_page == 1
render ‘collection-layout’
%}

Additional info

Pagination is showing pages incorrectly. For example, 16 products per page, 49 total products, 7 of which are draft. The collection page shows that there are 4 pages, but there should only be 3.

According to sidekick this is because the collection count includes draft products. But sidekick was unable to provide a source for this.

I attempted to use the following:

{% assign available_products = collection.products | where: “available”, true %}

but that process removes the manual collection sorting.

Any ideas on how to deal with this other than to remove the draft products?

What type of topic is this

General discussion

Hi @fcd

Yes, Shopify’s paginate tag does include draft products in its count. This is a known platform behavior - the pagination is calculated server-side based on the total collection size, which includes draft (unpublished) products. However, draft products are excluded from rendering inside {% for product in collection.products %}, which is why you end up with incorrect page counts and partially-filled or empty final pages.