Is there a limit to the number of products that can be displayed on Shopify's infinite scroll

I'm looking to incorporate infinite scroll on my product collections page, and I've implemented the following code in my collection-template.liquid file:

<div id="js-ajax-loop" class="ProductList ProductList--grid Grid" data-mobile-count="{{ mobile_items_per_row }}" data-desktop-count="{{ desktop_items_per_row }}">
    {% for product in collection.products %}
      {% if product.available %}
        <div class="Grid__Cell 1/{{ mobile_items_per_row }}--phone 1/{{ tablet_items_per_row }}--tablet-and-up 1/{{ desktop_items_per_row }}--{% if section.settings.filter_position == 'drawer' %}lap-and-up{% else %}desk{% endif %}">
          {%- render 'product-item', product: product, show_product_info: true, show_vendor: section.settings.show_vendor, show_color_swatch: section.settings.show_color_swatch, show_labels: true -%}
        </div>
      {% endif %}
    {% endfor %}
  </div>
  <div id="js-ajax-pagination">
    {% if paginate.next %}
      <a href="{{ paginate.next.url }}">Loading More</a>
    {% endif %}  
  </div>

In addition to this, I've included the following code in my custom.js file:

  document.addEventListener("DOMContentLoaded", function() {
    var endlessScroll = new Ajaxinate({
      container: '#js-ajax-loop',
      pagination: '#js-ajax-pagination'
    });
  });

Initially, everything appeared to be working fine. However, I noticed that I could only scroll through up to a maximum of 48 products.

Upon inspecting my schema, I found the setting for Products per Page:

"type": "range",
"id": "grid_items_per_page",
"label": "Products per page",
"min": 4,
"max": 100,
"step": 4,
"default": 16

Having increased this value from 48 to 100, and made adjustments within Shopify itself as well:

https://i.sstatic.net/r5JgP.png

Despite these changes, only 48 out of my total of 80 active products are being displayed.

If anyone has any insights on how I can resolve this issue and ensure all products are shown, it would be greatly appreciated.

(PS: I am currently making these modifications on a non-live theme. Would altering the count on the live theme potentially solve the issue?)

Answer №1

I found a solution that worked for me by using the paginate method, like so:

<div id="js-ajax-loop" class="ProductList ProductList--grid Grid" data-mobile-count="{{ mobile_items_per_row }}" data-desktop-count="{{ desktop_items_per_row }}">
    {% paginate collection.products by 100 %}
    {% for product in collection.products %}
      {% if product.available %}
        <div class="Grid__Cell 1/{{ mobile_items_per_row }}--phone 1/{{ tablet_items_per_row }}--tablet-and-up 1/{{ desktop_items_per_row }}--{% if section.settings.filter_position == 'drawer' %}lap-and-up{% else %}desk{% endif %}">
          {%- render 'product-item', product: product, show_product_info: true, show_vendor: section.settings.show_vendor, show_color_swatch: section.settings.show_color_swatch, show_labels: true -%}
        </div>
      {% endif %}
    {% endfor %}
    {% endpaginate %}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using mthaml to process my PHP variables within :javascript

Is there a way to prevent MTHAML from altering my variables? I'm currently using a PHP port of MTHAML with the same syntax. Check out https://github.com/arnaud-lb/MtHaml For example, when I include variables like this: :javascript if (#{$re ...

What is the method for including HTML special characters in d3.js?

I am attempting to incorporate the degree symbol in my HTML code using ° const degreeNum = d3 .select(`#windBox${order}`) .append("text") .attr("x", 250) .attr("y", 130) .style("font", "bold 50px sans-serif") ...

How can one effectively monitor the progress of multiple ajax requests in Angular8 for optimal professionalism?

There is a single completed variable made up of 6 parts, outlined below: selectedCandidateData: Candidate = { candidateBasic: null, experienceList: null, educationList: null, certificationList: null, candidateAbout: null, }; Each part ...

Designate categories by utilizing the x-amz-tagging request header

I'm in the process of creating a Node program to upload files to aws s3, and I'm having trouble figuring out how to specify the x-amz-tagging with the request header. I attempted a solution, but it's not working as expected! function crea ...

What could be causing my button code to malfunction after implementing AJAX in ASP.NET?

One of my ASP.NET buttons is designed to clear textboxes using Ajax, as shown below: <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> & ...

Limit the 'contenteditable' attribute in table data to accept only integers

I have a question regarding editing table data row. Is there a way to restrict it to only integers? Thank you for your assistance! <td contenteditable="true" class="product_rate"></td> ...

Divide the list of commitments into separate groups. Carry out all commitments within each group simultaneously, and proceed to the next group

My Web Crawling Process: I navigate the web by creating promises from a list of website links. These promises act as crawlers and are executed sequentially. For instance, if I have 10 links, I will crawl the first link, wait for it to complete, then move ...

How can we integrate this icon/font plugin in CSS/JavaScript?

Check out the live demonstration on Jsfiddle http://jsfiddle.net/hc046u9u/ <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materializ ...

Opting to utilize a multidimensional JavaScript array or object is a more efficient method

Here is a breakdown in JSON format: jsonResponse Folder 01 Product 01 - Folder 01 Product 02 - Folder 01 Product 03 - Folder 01 Folder 02 Product 01 - Folder 02 Product 02 - Folder 02 Product 03 - Fo ...

Use jQuery or javascript to eliminate the 'Webpage Dialog' from the 'showModalDialog' window

At one point on the page, I have a line of code that looks like this: onclick="window.showModalDialog("http://rauf-thecoder.blogspot.com/");" When executed, it displays the following: Is there a way to eliminate the title bar text for the Webpage Dialog ...

Showing JSON response on an HTML page using AngularJS

I have limited experience with JavaScript and/or Angular, but I am required to utilize it for a research project. My task involves showcasing the JSON data returned by another component on a webpage. Here is how the process unfolds: When a user clicks on ...

Storing data in localStorage and serializing it using JSON.stringify and

Currently, I am developing a project that enables users to share memories of places they have visited and also tracks the location and time when the memory was recorded. One hurdle I'm facing involves incorporating localStorage into the application. I ...

If I needed to include extra information within an element for easy retrieval using JavaScript

Using PHP, I have generated a list of products in a <select> element. Each product has a weight that I want to store within each <option> so I can access it later using Javascript. Is there a way to include the weight data directly in the HTML ...

Unable to retrieve Celery task outcome in Django version 1.11

I am trying to retrieve Celery task results in Django using AJAX. Here is the view I have: def ajax_brand_count(request, task_id): extra_data = brand_count.AsyncResult(task_id) print("1", extra_data.state) print("2", extra_data.get()) if e ...

Linking promises together and including extra information to be passed along with the following promises

Can you help me with chaining promises and adding extra data to be returned in the .then, while also making another API request in the process? I've come across similar discussions, but none that show how to include additional data and carry it throug ...

Tips for determining the quantity of current users in a node.js (express) site?

As I work on building my website with node.js and express.js, I have a specific goal in mind. I want to create a new feature that will allow me, as the developer/administrator, to easily track the number of active visitors on the site. This way, I can stra ...

How can we use JavaScript to convert base 10 colors or hex colors to ANSI colors?

I am searching for a method to convert base 10 colors or hex colors into ANSI colors that are compatible with the terminal. For instance, \u001b[31m represents red in ANSI colors. Any suggestions on how this can be achieved using JavaScript code or a ...

What steps do you take to address the CORS error while implementing Google One Tap?

My attempt to implement Google One Tap is encountering issues as outlined in this guide. The errors displayed in the Chrome console are troubling. Access to XMLHttpRequest at 'https://accounts.google.com/gsi/status?client_id=my_client_id&as=yz1XX ...

How can you switch a line on and off in Chart js without needing to

My current project involves using chart.js, and I have three lines - A, B, and C. Is it possible to create a chart that displays only lines A & B, with line C crossed out in the legend but not shown on the graph itself? Essentially, I want to be able to to ...

An error occurred: Unable to access the 'indexOf' property of an undefined variable within the angularjs framework

Hello world of coding, I am a newbie seeking help from experts. The angularJs error I've encountered in the file has been identified and is related to this code snippet: if( searchItemsSmallLetters.indexOf(searchTextSmallLetters) !== -1){ Your assi ...