How to return products in stock via API REST using SearchCriteria?
-
14-04-2021 - |
Question
I have an integration that must get my products in stock via the Magento 2 API using SearchCriteria.
How could I filter it, since it's inside my custom_attributes
?
Solution
You can filter normally as any other attribute. Use this URL below to request, I'm using the rule "if it's greater than 0 than" to get products, and I put the limit of 50 products. The counting of total products is included during the return as you can see in the image.
https://www.mystore.com/ca_en/rest/all/V1/products?
searchCriteria[filterGroups][0][filters][0][field]=is_in_stock&
searchCriteria[filterGroups][0][filters][0][value]=0&
searchCriteria[filterGroups][0][filters][0][conditionType]=gt&
searchCriteria[pageSize]=50
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange