How do I circumvent Shopify’s 1,000 paginate limitation?

How do I circumvent Shopify’s 1,000 paginate limitation?

theDMM
Excursionist
35 0 25

The webpage we built to show all inventory in a listicle format paginates at 1,000 products even when setting the limit to 5000 in the liquid code file as shown in the screenshot below:

Screenshot 2024-05-24 at 3.03.29 PM.png

How can we bypass or circumvent the apparent pagination limit of 1000 that seems to be in place?

 

Considerations:
- Shopify might have an API call limit that is causing this issue.

- Would upgrading to Shopify Plus remove this API call limitation? If so, hopefully, this isn't the only option (Shopify Plus is expensive).

 

Any information would be greatly appreciated as I could not find a clear answer on the web. Thank you.

 

Perhaps @ShopifyDevSup can chime in?

 

Cheers,
Connor
Replies 4 (4)

Made4uo-Ribe
Shopify Partner
9552 2276 2823

Hi @theDMM 

 

At this moment, Shopify still have limit on the pagination. However, you can use an infinite scroll to load the products when the customer scrolls down. In this way, your page looks like you have more than the limit of products showing.

If this fixed your issue, Likes and Accept as Solution are highly appreciated. Coffee tips fuel my dedication.
Get experienced Shopify developers at affordable rates—visit Made4Uo.com for a quick quote!
Need THEME UPDATES but have custom codes? No worries, for an affordable price.
Create custom Shopify pages effortlessly with PageFly's drag-and-drop ⚙️.
theDMM
Excursionist
35 0 25

Thank you for your reply @Made4uo-Ribe 

 

To clarify, I'm not asking about workarounds for the 1,000 item pagination limit from a user experience perspective (e.g., infinite scroll).

 

1) Instead, I'm trying to determine if this limit is adjustable. Our automated inventory data extraction process, which relies on accessing the full listicle data through an Excel button click, is currently capped at 1,000 items. Could you please direct me to the documentation or settings where this limit is defined? Or how we can increase the number past 1,000?

 

2) If this pagination limit cannot be extended, we will need to redesign our automated data extraction method that currently exports inventory data to an excel sheet at the click of a button. If #1 isn't possible and you have any alternative ideas for this, please let me know.

 

Thank you.

Cheers,
Connor
theDMM
Excursionist
35 0 25

Hello @Made4uo-Ribe , does this same limit of 1,000 apply to Shopify Plus accounts? Is there any possible way to list all products, not just 1,000 on a page?

Cheers,
Connor

pantherandcub
Shopify Partner
1 0 0

Hey there, funny enough, i have found a way. 

Probably about time I help someone else out rather than receiving help. It uses AJAX. 
This setup was an attempt to bypass the 1000 limit make swatches. It worked but a little slow and I don't care enough so ended up trashing it. But i'm sure it could be modified to do whatever you want. Pulling this out of my trash bin lol. 

Heres how you set it up
Create two new files in your templates folder (You may want both) 

collection.full-count.liquid
collection.json.liquid 

put this code in each.. 


collection.full-count.liquid

{% layout none %}
{{ collection.all_products_count }}


collection.json.liquid 

{% layout none %}
{
"title": {{ collection.title | json }},
"description": {{ collection.description | json }},
"total_products": {{ collection.products_count | json }},
"products": [
{% paginate collection.products by 250 %}
{% for product in collection.products %}
{
"id": {{ product.id | json }},
"title": {{ product.title | json }},
"handle": {{ product.handle | json }},
"url": {{ product.url | json }},
"featured_image": {{ product.featured_image | img_url: '300x300' | json }},
"price": {{ product.price | money | json }}
}{% unless forloop.last %},{% endunless %}
{% endfor %}
{% endpaginate %}
]
}


Now the javascript

async function fetchAllCollectionProducts(collectionUrl) {
let allProducts = [];
let currentPage = 1;
let collectionData = null;

const fetchPage = async (page) => {
const url = `${collectionUrl}?view=json&page=${page}`;
console.log(`Fetching page ${page}: ${url}`);
const response = await fetch(url);
if (!response.ok) throw new Error('Network response was not ok');
const data = await response.json();
console.log(`Page ${page} data:`, data);
return data;
};

const firstPageData = await fetchPage(1);
collectionData = {
title: firstPageData.title,
description: firstPageData.description,
total_products: firstPageData.total_products
};
allProducts = allProducts.concat(firstPageData.products);

const productsPerPage = firstPageData.products.length;
const totalPages = Math.ceil(firstPageData.total_products / productsPerPage);

for (let page = 2; page <= totalPages; page++) {
const data = await fetchPage(page);
allProducts = allProducts.concat(data.products);
console.log(`Fetched page ${page} of ${totalPages}, total products so far: ${allProducts.length}`);
}

return {
...collectionData,
products: allProducts
};
}

// Initialize collection fetcher when the DOM is loaded
document.addEventListener('DOMContentLoaded', function() {
const collectionUrl = '/collections/all';
console.log('Fetching collection:', collectionUrl);
fetchAllCollectionProducts(collectionUrl)
.then(data => {
console.log('All collection products:', data);
console.log('Total products fetched:', data.products.length);
})
.catch(error => console.error('Error fetching collection products:', error));
});



__

This is setup to loop through a collection i named 'all' which puts all products over 0 dollars in by default. Just modify this for your use case. 

From memory you can go to two URL's inparticular to make sure the information is feeding through if your console logs come up with errors. Assuming you're still looping over collection 'all' 
yoursite.com/collections/all?full-count
yoursite.com/collections/all?view=json

Full count should display the full number of the collection, and the json should show the information you're pulling.