Is there a per product metafields limit when creating a large amount of metafields for a product?

Does aproduct have a limit for the amount of metafields it can have?

In my case I need to create around 40k metafields on one of the products in my client’s store. I’m executing in batches of a few hundred metafields using a method similar to this:

https://ecommerce.shopify.com/c/shopify-apis-and-technology/t/bulk-updating-variant-metafields-487966

When I reach around 17k metafields I get a 502 error from Shopify. Sometimes it’s 19k metafields. So maybe it’s a number of metafields/time limit? I’m puzzled.

This is the message I get: “Due to an unexpected technical problem, shop is currently unavailable…”

In my case I need to create around 40k metafields on one of the products

Why? What are you doing that would need so many? I’d be questioning your data strategy here.

Say you want to create a metafield for each of the products and the store has 40k products. That’s the only way I figured out without having the process run for DAYS, given the request limits that the REST api enforces (creating one metafield for each of the products vs one product that stores all the metafields). Shopify doesn’t have batch updates so what else can I do? ¯_(ツ)_/¯. Can I do it differently? I’d be happy to change my strategy if there is a better one.

There’s a size limit (65,535 chars) for the value of a metafield so trying to jam the values for all 40k items into a single products metafields isn’t a sound idea.

Combining multiple metafields per product can be a useful strategy but that depends on how the values need to be maintained and used.

Unless you’re planning on updating the values all the time what’s the issue with taking some time to get the content in? If you need to update the value all the time (like hourly) then perhaps a metafield isn’t the right place that you should be storing that data.

1 Like

No no no :slight_smile: I’m putting a little bit of content into a number of metafields under my namespace in that product. I’m aware of the limits. And that’s a one-off really. Then the values of the metafields are updated sporadically. So there is no better way I understand?