我是 Akeneo PIM API 的新手,目前使用“获取”连接器通过 API 获取产品和类别信息。
我已经设法使访问正常工作,并且可以根据过滤器返回产品信息,但我很难找出实际返回了多少产品。
根据 API 文档,有一个名为“with_count”的查询参数,如果设置为“true”,您可以在响应中看到产品计数。
我在请求中将其设置为 true:
http://example.com/api/rest/v1/product-models?with_count=true&pagination_type=search_after&limit=1&search={"brand":[{"operator":"IN","value":["brand_fred_perry"]}],"department":[{"operator":"IN","value":["department_polo_shirts"]}]}
但我在回复中看不到它:
{
"_links":{
"self":{
"href":"http://example.com/api/rest/v1/product-models?with_count=true\u0026pagination_type=search_after\u0026limit=1\u0026search=%7B%22brand%22:%5B%7B%22operator%22:%22IN%22,%22value%22:%5B%22brand_fred_perry%22%5D%7D%5D,%22department%22:%5B%7B%22operator%22:%22IN%22,%22value%22:%5B%22department_polo_shirts%22%5D%7D%5D%7D"
},
"first":{
"href":"http://example.com/api/rest/v1/product-models?with_count=true\u0026pagination_type=search_after\u0026limit=1\u0026search=%7B%22brand%22:%5B%7B%22operator%22:%22IN%22,%22value%22:%5B%22brand_fred_perry%22%5D%7D%5D,%22department%22:%5B%7B%22operator%22:%22IN%22,%22value%22:%5B%22department_polo_shirts%22%5D%7D%5D%7D"
},
"next":{
"href":"http://example.com/api/rest/v1/product-models?with_count=true\u0026pagination_type=search_after\u0026limit=1\u0026search=%7B%22brand%22:%5B%7B%22operator%22:%22IN%22,%22value%22:%5B%22brand_fred_perry%22%5D%7D%5D,%22department%22:%5B%7B%22operator%22:%22IN%22,%22value%22:%5B%22department_polo_shirts%22%5D%7D%5D%7D\u0026search_after=qtTUjg%3D%3D"
}
},
"_embedded":{
"items":[
{
"_links":{
"self":{
"href":"http://example.com/api/rest/v1/product-models/aw19m3600106"
}
},
"code":"aw19m3600106",
"family":"default",
"family_variant":"default_size",
"parent":null,
"categories":[
"fred_perry_polo_shirts",
"fred_perry",
"polo_shirts"
],
"values":{
"brand":[
{
"locale":null,
"scope":null,
"data":"brand_fred_perry"
}
],
"color":[
{
"locale":null,
"scope":null,
"data":"color_burgundy"
}
],
"department":[
{
"locale":null,
"scope":null,
"data":"department_polo_shirts"
}
],
"name":[
{
"locale":null,
"scope":null,
"data":"Fred Perry M3600 Burgundy Polo Shirt"
}
]
},
"created":"2020-03-26T08:40:24+00:00",
"updated":"2020-03-26T08:40:24+00:00",
"associations":{
"PACK":{
"products":[
],
"product_models":[
],
"groups":[
]
},
"SUBSTITUTION":{
"products":[
],
"product_models":[
],
"groups":[
]
},
"UPSELL":{
"products":[
],
"product_models":[
],
"groups":[
]
},
"X_SELL":{
"products":[
],
"product_models":[
],
"groups":[
]
}
}
}
]
}
}
API 文档还说我应该在响应中看到“current_page”,但正如您在上面看到的那样,它不存在......
编辑
事实证明,将“pagination_type”设置为“search_after”时我看不到它。