how to apply filtering on products of collectionByHandle object ?

Highlighted
Shopify Partner
23 0 0

We are building mobile app for our Shopify site. We are using shopify storefront api to works with products and collections. In our app, the flow is that first we are displaying all the collections with it's image and title. Whenever user click on any of collection user will be redirected to the Product List screen, where we are displaying the products list of particular clicked collection.

Here is the query that we used to get the products list of particular collection by it's handle : 

query MyQuery {
  collectionByHandle(handle: "") {
    products(first: 10) {
      edges {
        node {
          id
          handle
        }
      }
    }
  }
}

Now, we want to filter the products base on the `product_type`, but there is no option to filter the query. 

 

Can anyone please help me how we can solve this issue ? Or any idea to get filter work on collection's products list ?

0 Likes
Highlighted
Shopify Staff
Shopify Staff
144 18 22

Hey @Q_2 

You can add the query param to filter by product type:

{
  products(first:5, query: "product_type:shirt"){
    edges{
      node{
        id
      }
    }
  }
}

 

Kevin_A | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes