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
We are required to list all of them, so we are not overfetching
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.
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).
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.
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
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.
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.
@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?
Tim and I chatted and this really needs to be available via liquid before 2048 variants rolls out to all merchants. Sounds like pagination will not work for the full 2048 variants which is unfortunate.
Failing to make all variants available via liquid can negatively impact not only their SEO, but their paid or free ads as well.
Structured data is used for both SEO and ads. Google needs the entire set of structured data to be present at the time the page renders in order to process it.
I think there is some misunderstanding to how that works…
Google does not require every variant to be visible in the HTML. It recommends that structured data reflects the visible content. If some variants are shown via JavaScript (especially in modern JS-rendered frameworks), Google is capable of parsing that, especially with JSON-LD.
Shopify’s new storefront renderer uses section rendering, lazy loading, etc. — it wouldn’t be doing that if it broke SEO for merchants. Shopify is literally partnered with Google and works closely to maintain eligibility.
Use JSON-LD to represent the structured data even if not all variants are rendered to users (as long as the important ones are).
Or, inject full variant data via JavaScript into the DOM in a — Google parses that just fine.
If you need to expose all variants for structured data:
Create a block and dump your variant data into it. That’s valid, crawlable, and what Google recommends.
You do not have to list all 500+ divs with every size/color permutation as part of visible HTML.
Using JavaScript to display structured data, although an option, isn’t reliable enough for shopping queries and they state as such in their documentation.
Using Product markup? Be aware that dynamically-generated markup can make Shopping crawls less frequent and less reliable, which can be an issue for fast-changing content like product availability and price. If you’re a merchant optimizing for all types of shopping results, make sure your server has enough computing resources to handle increased traffic from Google.
Merchant Center validates the product feed by matching what’s on the landing page and the structured data. So if JavaScript is unreliable to make sure the most up to date information is provided, there is no way for merchants ensure their structured data is correct except for using liquid/html.
Shopify is literally partnered with Google and works closely to maintain eligibility.
Not every feature developed by Shopify is run by Google.
I’ve spoken with the SEO team at Shopify and have made them aware of launched code for their structured data that violated Google’s guidelines which they later changed. Shopify tries to keep up with Google and SEO, but assuming everything Shopify makes has been vetted by Google is ridiculous.
I am literally saying that this doesn’t work for variants above 250. That’s the entire point of this thread.
@Tim-Shopify Given this update, has anything changed here or is this still an open issue for your team? I still don’t see the full variant options showing up in the structured data provided by Shopify’s own filter.