休息 Api 获取产品如何通过过滤器“状态”和“可见性”
Rest Api to get Products how to pass filter “status” and “visibility”
$apiUrl = 'http://192.168.1.7/xxxx/api/rest';
...
$oauthClient->setToken($_SESSION['token'], $_SESSION['secret']);
$resourceUrl = "$apiUrl/products?page=1&limit=5";
$oauthClient->fetch($resourceUrl, array(), 'GET', array('Content-Type' => 'application/json', 'Accept' => '*/*'));
$productsList = json_decode($oauthClient->getLastResponse());
print_r($productsList);
exit;
I have getting list of product using rest api but i wants a filter
with status=1 and visibility=4
$apiUrl/products?page=1&limit=5&filter[0][attribute]=status&filter[0][eq]=1&filter[1][attribute]=visibility&filter[1][eq]=4
But before trying make sure that you are allowed to view and filter by
status and visibility.
You can set the allowed attributes from System->Web Services->Rest
Attributes and select the role you are using (admin, customer or
guest).
$apiUrl = 'http://192.168.1.7/xxxx/api/rest';
...
$oauthClient->setToken($_SESSION['token'], $_SESSION['secret']);
$resourceUrl = "$apiUrl/products?page=1&limit=5";
$oauthClient->fetch($resourceUrl, array(), 'GET', array('Content-Type' => 'application/json', 'Accept' => '*/*'));
$productsList = json_decode($oauthClient->getLastResponse());
print_r($productsList);
exit;
I have getting list of product using rest api but i wants a filter with status=1 and visibility=4
$apiUrl/products?page=1&limit=5&filter[0][attribute]=status&filter[0][eq]=1&filter[1][attribute]=visibility&filter[1][eq]=4
But before trying make sure that you are allowed to view and filter by status and visibility.
You can set the allowed attributes from System->Web Services->Rest Attributes and select the role you are using (admin, customer or guest).