这是我到目前为止所得到的,但它不起作用。
public function getCompleteness(){
$searchBuilder = new AkeneoSearchBuilder();
$searchBuilder->addFilter('completeness', '=', 100);
try {
$products = $this->apiClient->getProductApi()->all(
50,
[
'search' => $searchBuilder->getFilters(),
'scope' => 'ecommerce'
]
);
} catch (HttpException $e){
echo "Message: " . $e->getMessage();
echo "Code: " . $e->getCode();
}
return $products;
}
}
这是我尝试使用Akeneo API的电话。
{{url}}/api/rest/v1/products?search={"completeness":[{"operator":"=","value":100,"scope":"ecommerce"}]}
如何使用GetCompleteness()方法产生一些结果?我有使用AkeneoSearchBuilder()的问题;
答案 0 :(得分:2)
当你这样做时:
$searchBuilder = new AkeneoSearchBuilder();
$searchBuilder->addFilter('completeness', '=', 100);
$products = $this->apiClient->getProductApi()->all(
50,
[
'search' => $searchBuilder->getFilters(),
'scope' => 'ecommerce'
]
);
它基本上意味着:“对于范围”未定义“的所有产品,请给我所有”电子商务“值”。
你想要达到的目标是(我猜):“对于所有在”电子商务“范围内完成的产品,请给我所有的价值”。
正如您可以阅读有关completeness filter的官方文档,您需要指定范围:
$searchBuilder = new AkeneoSearchBuilder();
$searchBuilder->addFilter('completeness', '=', 100, ['scope' => 'ecommerce']);
现在您可以通过调用:
来检索它们的值$products = $this->apiClient->getProductApi()->all(
50,
[
'search' => $searchBuilder->getFilters()
]
);
请注意,我在此处删除了“范围”参数。
要恢复: