Ad

Shopify - Heavy Liquid Loop

- 1 answer

I'd like to know if this type of loop would cause performance problems. It would happen in a product grid.

(not the correct syntax, but shows my thought process)

for product in shop.all-products
    for tag in product.all-tags
        if tag contains 'string'
            show product

I'm asking for a shop that currently has about 500 products and each product may have up to about ten tags. So this would loop through all products in the store and all tags in each product.

It's handled server-side, so I'm also wondering if the HTML output is cached so that the Liquid won't need to run every time?

Thanks

Ad

Answer

It will cause an overload on the system.

You can achieve this using a custom collection template with product fields listed in json and AJAX

You can use the idea implemented in this - https://help.shopify.com/themes/customization/store/enable-autocomplete-for-search-boxes

New tutorial with new features from Shopify - https://help.shopify.com/en/themes/development/predictive-search

Ad
source: stackoverflow.com
Ad