Joint session with Vercel: How to build intelligent storefronts (May 15th)

Should I use SKU field in documents or create separate SKU document type?

5 repliesLast updated: Nov 29, 2025

Hi all. I have multiple document types that together form a product catalog. I will need an easy way to query by SKU, and I am not sure what the best way to proceed. Should I add SKU to individual documents and then use some aggregate query for it? Or should I create a new document type that will hold the unique global SKU and reference the product document types?
AI Update

Based on the information about product catalog management in Sanity, I'd recommend adding SKU directly to your individual product documents rather than creating a separate document type. Here's why:

Direct SKU approach (recommended):

Why this works better:

If you need to query across multiple document types:

You can use a GROQ query that searches multiple types at once:

*[_type in ["productType1", "productType2", "productType3"] && sku == $sku][0]

Or if you want to find all documents with a specific SKU regardless of type:

*[defined(sku) && sku == $sku]

When you might consider a separate SKU document:

The separate document approach only makes sense if:

But for most product catalogs, the direct approach is cleaner and more maintainable. As mentioned in the structured content patterns for e-commerce guide, storing SKUs directly on product documents (often within variant arrays) is the standard pattern in e-commerce implementations.

Show original thread
5 replies

Was this answer helpful?

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Related contributions