Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
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:
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?
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.
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.
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?
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.
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024