No liquid support for variants above 250

Correct me if I’m wrong, but there is still no way in liquid to get all of the variants?

The instructions and new liquid APIs seem to only support selecting specific variants out of the full set.

My app has to list all variants for Google SEO purposes. The old way to iterate over product.variants sounds like it will only ever output 250.

We can’t “eliminate overfetching or defer loading variant information” because

  1. We are required to list all of them, so we are not overfetching
  2. We cannot defer because search engines (e.g. Google) require all variant data on page load when the HTML is rendered without any interaction events

Based on this document, liquid cannot support listing any variants beyond 250. That means merchants will not be able to qualify for search enhancements, Merchant Center, or other advertisements. I’m shocked that this use case was overlooked.

2 Likes

We have similar issue in our app where we need all variants and this change is going make things really hard for us.

Hey @Ilana_Davis!

Would pagination like mentioned here work? Display the list of all variants

Hey @KyleG-Shopify,

Yes, it seems like pagination can work. I would have expected to see pagination mentioned in the docs for high variants as a solution, so that’s great.

However, I think the pagination docs are wrong, or the system actually supports a higher page_size than 50 as documented.

My dev store has 560 variants. The following code correctly returns all 560 at once.

{% paginate product.variants by 2049 %}
  {% for variant in product.variants %}
    {% assign prod_variant_count = prod_variant_count | plus: 1 %}
    {{ variant.id | json }}
  {% endfor %}
{% endpaginate %}

Total variants - {{ prod_variant_count }}

This works by making the page_size be large enough to get all the variants. The docs for pagination says it only supports up to 50. Setting page_size to 50 only returns 50 (probably just the first page).

It would be great to clarify in the docs

  1. That pagination can work for high variants, and
  2. That pagination can support a higher page_size
3 Likes

Thanks for getting back to me. Glad pagination will work. I’ll look in to see what is expected here so we can get clarification on the proper supported amount.

1 Like

Agree with @Ilana_Davis

I’m not sure if the page size can support a higher number than 50 or what the upper limit is. If this higher page_number is not official, will Shopify revert it later? I want to make sure it’s safe for production.

My product has 1386 variants. I’ve adjusted the page_size to 2049. But it can only return the first 1,000 variants. Therefore, this liquid hack cannot return all variants

1 Like

Out of curiosity, and to help with a discussion we are having internally: what is a/the scenario is which a merchant has a valid use case for 100+ variants?

@Jacco
My use case is to create a bundle builder page where customers can select any particular number of variants from a collection and get a discount. Let’s say there are 20 products in a collection. The user wants to show these products on a page, where customers can pick and mix.

I’ve created a thread with more details.

1 Like

It’s easy to get above 100 when you’re considering custom made products or colors. Yes, there could be an argument to find a break point where they can be products, but sometimes that causes more confusion because those products are on different product URLs.

For the average merchant, metafields are still a confusing concept and linking products with variants on different pages can be a lot to digest. A few come to mind:

  • sweatshirt in many different colors, patterns, and sizes vs a t-shirt or tank top
  • yarn colors on different types of yarn
  • cell phone cases in various styles with however many phone brands and versions

I suspect most merchants will be closer to 250 than 2048 but I can only presume Shopify is setting that number to be excessively high so they don’t have to revisit this in the future.

1 Like

Hey @KyleG-Shopify

Any update from the team?

Hey folks, thanks for your patiences. Here are the current constraints:

  • the product.variant array with have up to 250 variants
  • paginate tag is documented to only support 50 per page, but atm will return up to 1000
  • the product_options api provides the “adjacent” variants and the “top down” availability (more details)
  • Storefront API can provide all options w/ availability in an encoded format, as well as, variants paginated at 250

As @Ilana_Davis mentioned, the vast majority of products will be below 250, but some merchants will go beyond this such as those examples mentioned.

@Ilana_Davis @Benny_Chan I’m reaching out directly because we’d love to discuss your use cases and see how we might satisfy them.

2 Likes

@Tim-Shopify can we use the paginate tag in prod, assuming it would return up to 1000? What do you suggest to us in this case since it is not documented like that?