Filter products by collection

Filter products by collection

roymap
Shopify Partner
1 0 0

Given that the REST product APIs are going away, how would we list products in a specific collection?  The REST list products endpoint supported a collectionId filter.

 

The graphQL Collection query doesn’t return products. And the graphQL products query doesn’t support a collectionId.

Replies 2 (2)

Made4uo-Ribe
Shopify Partner
8363 2000 2460

 

Hi @roymap 

 

This one works with collection ID

{
  node(id: "COLLECTION_ID") {
    ... on Collection {
      id
      title
      description
      handle
      updatedAt
      products(first: 5) {
        edges {
          node {
            id
            title
          }
        }
      }
    }
  }
}

 

 

 

 

Result here:

Made4uoRibe_0-1715230196115.png

 

If this fixed your issue Likes and Accept as Solution is highly appreciated. Coffee tips fuels my dedication.
Get EXPERIENCED Shopify developers at affordable rates—visit Made4Uo.com for quick quote!
Do not lost your Shopify store! Get FREE trial with ✔️ Rewind Backup: Automatic, reliable, stress-free.
Need THEME UPDATES but has custom codes? No worries, contact us for affordable price.

Eric-HAN
Shopify Partner
196 25 20

Hi, there

 

You could refer to this  graphQL   and  change the id of specifed collection  d

 

query {
  collection(id: "gid://shopify/Collection/451514401051") {
    products(first: 10) {
      edges {
        node {
          id
          title
          description
          priceRange {
            minVariantPrice {
              amount
              currencyCode
            }
            maxVariantPrice {
              amount
              currencyCode
            }
          }
        }
      }
    }
  }
}

 

- Helpful? Please hit Like and mark it as a solution
Want to modify or custom changes on store? Let me help.
- Feel free to Email Me    Buy Me A Coffee