简体   繁体   English

如何根据 product_type 过滤使用 shopify 店面 graphQL api 中的 collectionByHandle 检索的产品?

[英]How to filter the products based on product_type, that are retrieved using collectionByHandle in shopify storefront graphQL api?

In our app, we are displaying the list of collections from the shopify store.在我们的应用程序中,我们显示 shopify 商店中的 collections 列表。 When user click on any of collection, it will redirect to product list, where all the products of that clicked collection will be displayed.当用户点击任何一个集合时,它将重定向到产品列表,其中将显示该点击集合的所有产品。

Here is the sample query which I used to get the products list of particular collection:这是我用来获取特定集合的产品列表的示例查询:

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

Now, I want filtering on products list.现在,我想过滤产品列表。 I want to display products base on product_type.我想根据 product_type 显示产品。 But there is no any option to filter the products.但是没有任何过滤产品的选项。

query option only available when you retrieve simple products listing using this query: query选项仅在您使用此查询检索简单产品列表时可用:

{
  products(query: "product_type:casual-things", first: 10) {
    edges {
      node {
        id
        title
        productType
      }
    }
  }
}

But, this query option not available on products node of collectionByHandle .但是,此query选项在collectionByHandleproducts节点上不可用。

Can, anyone help me how to implement filter option using Shopify storefront graphQL api in collectionByHandle query?谁能帮助我如何在collectionByHandle查询中使用 Shopify 店面 graphQL api 实现过滤器选项?

The products connection doesn't have a query argument. products连接没有查询参数。 You have basically access to fetching all products within that collectionByHandle and then filtering them client-side.您基本上可以访问该collectionByHandle中的所有产品,然后在客户端过滤它们。 You must have to use liquid for these types of nested features.对于这些类型的嵌套特征,您必须使用liquid

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM