Is there is a built in rest API to get ALL products with a specific attribute_code
ex. this API https://domain.com/index.php/rest/V1/products/:productID returns
..
<item>
<attribute_code>featured</attribute_code>
<value>0</value>
</item>
..
1 Answer 1
Should try with Search using REST APIs: http://devdocs.magento.com/guides/v2.1/howdoi/webapi/search-criteria.html
You should try with GET:
http://{magento_host}/rest/V1/products? searchCriteria[filter_groups][0][filters][0][field]=featured& searchCriteria[filter_groups][0][filters][0][value]=0 searchCriteria[filter_groups][0][filters][0][condition_type]=eq
<?php
$userData = ["username" => "admin", "password" => "admin123"];
$ch = curl_init("http://mage215.loc/rest/V1/integration/admin/token");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($userData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Content-Lenght: " . strlen(json_encode($userData))));
$token = curl_exec($ch);
$ch = curl_init("http://mage215.loc/rest/V1/products?
searchCriteria[filter_groups][0][filters][0][field]=featured&
searchCriteria[filter_groups][0][filters][0][value]=0
searchCriteria[filter_groups][0][filters][0][condition_type]=eq");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); // method
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($emailcontent));
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Authorization: Bearer " . json_decode($token)));
$result = curl_exec($ch);
$result = json_decode($result, 1);
echo '<pre>';print_r($result);
Explore related questions
See similar questions with these tags.