在shopify中使用Storefront API过滤产品

Aka*_*shi 6 storefront shopify shopify-app

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

.products(第一个:10,查询:“ tag:blue AND product_type:sneaker”){$ 0 ...}

那么,谁能帮助我们搜索带有子键的子键,例如变体选择选项?

我们期望查询格式如下:.products(first:10,query:“ selectedProductVarient.option1:M”){$ 0 ...}

小智 0

您无法将查询参数添加到嵌套连接,但ProductVariants() 查询参数采用所有这些过滤器参数:

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

Run Code Online (Sandbox Code Playgroud)

option_1参数是选项的名称(“尺寸”、“颜色”等),而不是分配给变体的值。您最好查询title.