I'm new to the Akeneo PIM API and currently using a "fetch" connector to grab product and category information via the API.
I've managed to get the access working fine and I can bring back product information based on filters but I'm struggling to find out how many products are actually being returned.
According to the API documentation, there's a query parameter called "with_count" and if set to "true" you can see the product count in the response.
I've set this to true in the request:
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"]}]}
But I can't see it in the response:
{
"_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":[
]
}
}
}
]
}
}
The API documentation also says I should be seeing "current_page" in the response but as you can see above it's not there...
Turns out I can't see it when setting the "pagination_type" to "search_after".
The pagination_type
"search_after
" is not compatible with the parameter with_count
.
As you don't need to retrieve a big amount of products, you can safely us the "page
" pagination_type
or remove this parameter as it's the default value and you should get back the product counter.
Here is the api documentation section that explains this: https://api.akeneo.com/documentation/pagination.html