使用 shopify 中的店面 API 筛选产品



我们正在使用 Storefront API 开发过滤器功能。我们可以使用下面给出的运算符编写查询以在父键(例如"product_type"(中进行搜索,但我们找不到在子键中进行搜索的方法。

.products(first: 10, query: "tag:blue AND product_type:sneaker") { $0
...
}

那么任何人都可以帮助我们在子键中搜索,例如变体选择选项?

我们期待这样的查询格式:

.products(first: 10, query: "selectedProductVarient.option1:M") { $0
...
}

不能将查询参数添加到嵌套连接,但 productVariants(( 查询参数采用所有这些筛选参数:

{
productVariants(first: 10, query: "tag:foo product_type:bar option_1:baz") {
nodes {
id
title
product {
productType
tags
}
}
pageInfo {
hasNextPage
endCursor
}
}
}

option_1参数是选项的名称("大小"、"颜色"等(,而不是分配给多属性的值。您最好查询title

最新更新