Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

Help with filtering products by brand in a Sanity.io structure

3 replies
Last updated: Jul 28, 2020
Hey all, can anybody see what is wrong with my structure, I can’t seem to filter the desk to show products by brand

S.list()
      .title('/product')
      .items([
        S.documentTypeListItem('product').title('All products').icon(AllIcon),
        S.listItem()
          .title('Products by brand')
          .child(
            // List out all brands
            S.documentTypeList('brand')
              .title('Products by brand')
              .child((brandId) => S.documentList()
                .schemaType('product')
                .title('Products')
                .filter(
                  '_type == "product" && $brandId in brands[]._ref'
                )
                .params({ brandId }))
          )
      ])
Jul 28, 2020, 7:19 AM
It’s already showing the brands but not the products inside each of these brands, correct? Have you tried replacing
&& $brandId in brands[]._ref
with
&& references($brandId)
?
Jul 28, 2020, 7:31 AM
It’s already showing the brands but not the products inside each of these brands, correct? Have you tried replacing
&& $brandId in brands[]._ref
with
&& references($brandId)
?
Jul 28, 2020, 7:31 AM
thank you
Jul 28, 2020, 7:33 AM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?