Sanity v3 upgrade: Getting undefined error for products schema

7 replies
Last updated: Dec 2, 2025
Hello,So I made the mistake of trying to integrate shopify into my project and upgrading to v3 at the same time haha.

I am pretty sure I did the update right, I am getting a undefined error for my products though. Was wondering if you guys can check my schema file as see if its v3 compliant
AI Update

I totally understand the pain of doing two major changes at once - that definitely makes debugging trickier! Let me help you figure out what's going on with your product schema for v3.

First, the good news: when using Sanity Connect for Shopify, the product data structure is actually handled automatically by the integration. You don't need to manually define a store object field in your schema - that's created automatically when Shopify products sync to your Sanity dataset.

What Actually Happens with Sanity Connect:

When you install and configure Sanity Connect for Shopify, it automatically creates product documents in your Sanity dataset. The Shopify data (title, variants, prices, etc.) appears in a read-only store property on these documents, but this is handled by the integration itself, not something you define in your schema.

Your Product Schema Should Look Like This for v3:

import {defineType, defineField} from 'sanity'

export default defineType({
  name: 'product',
  title: 'Product',
  type: 'document',
  fields: [
    // Add your CUSTOM fields here - not the store object
    defineField({
      name: 'customDescription',
      title: 'Custom Description',
      type: 'text',
    }),
    defineField({
      name: 'seo',
      title: 'SEO',
      type: 'object',
      fields: [
        {name: 'title', type: 'string'},
        {name: 'description', type: 'text'}
      ]
    })
    // The 'store' object with Shopify data is added automatically
  ]
})

Key v3 Migration Points:

  1. Use defineType and defineField - This is the v3 standard for better TypeScript support
  2. Only define YOUR custom fields - Don't try to define the store object
  3. The store property appears automatically after sync completes

Common Causes of Your Undefined Error:

  1. Initial sync hasn't completed - After connecting Sanity Connect, it takes time for products to sync. Check your Sanity project's "Connect" section to see sync status.

  2. Accessing data incorrectly in queries - Shopify data lives under store, so your GROQ queries need:

    *[_type == "product"]{
      _id,
      "title": store.title,
      "slug": store.slug.current,
      "variants": store.variants,
      customDescription
    }
  3. Frontend code using wrong paths - Access product.store.title, not product.title

  4. Schema type name mismatch - Make sure your schema uses name: 'product' (or whatever document type Sanity Connect is syncing to)

Quick Debugging Steps:

  1. Check if products exist: Go to your Studio and look for product documents. Do they exist?

  2. Inspect a product document: Open one and click the three dots → "Inspect" to see the raw JSON. You should see a store object with Shopify data inside it.

  3. Verify the sync: In your Sanity project dashboard, check the Sanity Connect settings to confirm the sync is active and completed.

  4. Check your query/component: Where exactly are you getting the undefined error? Share the specific code line and error message if you can - that'll help pinpoint whether it's a schema issue, query issue, or frontend rendering issue.

The most likely culprit is either that the initial sync hasn't finished yet, or your code is trying to access Shopify fields directly instead of through the store object. Let me know what you find when you inspect a product document!

Show original thread
7 replies

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.

Was this answer helpful?