Limit Product in a Collection to 20 (Liquid Code Question)

Limit Product in a Collection to 20 (Liquid Code Question)

rawalarm
Tourist
9 0 1

I've done some research though couldn’t find a simple explanation of what code snippet to use to limit the products in a collection.

 

I appreciate that a "forloop" code might do the trick, though I couldn't find any clear indication of where and how to implement it. 

 

Hope you can help!

 

This is my current collection code:

 

 

{
  "sections": {
    "product-grid": {
      "type": "main-collection-product-grid",
      "settings": {
        "products_per_page": 40,
        "image_ratio": "adapt",
        "show_secondary_image": false,
        "add_image_padding": false,
        "show_image_outline": false,
        "show_vendor": false,
        "show_rating": false,
        "enable_filtering": true,
        "enable_sorting": true,
        "collapse_on_larger_devices": false
      }
    }
  },
  "order": [
    "product-grid"
  ]
}

 

 

 

Replies 4 (4)

Rohail_Ali_12
Shopify Partner
93 12 14

Hello there,  try to change this value: "products_per_page": 40, try to change 40 to any other number to see is working or not.

If helpful then please Like and Accept Solution.
Feel free to contact me for your Website Tasks: info@rsdigitals.com
Explore Premium Themes with Editable Creatives: https://www.rsdigitals.com/
rawalarm
Tourist
9 0 1

Thanks for the reply.

 

I think that would just limit the page size, though by scrolling down it would reveal the rest of the products.

Please correct me if I am wrong.

TheThisThat
Shopify Partner
64 3 17

I am also looking on how to limit a collection to a certain number of items. I tried

{%- for product in collection.products limit:20 -%} but this also only limits the products to the page rather than to the entire collection. 
a little of this and a little of that
LMiller
Shopify Partner
18 0 6

Did you find an answer to this?