我正在开发本机应用程序,需要根据类别获取产品列表。
就像当用户点击一个类别时,我必须显示该类别中的产品列表。
我尝试了一项服务,但它只给了三个字段作为回报
http://www.dexample.com/index.php/rest/V1/categories/1680/products
响应
{
"sku": "FB-Bridgewater",
"position": 1,
"category_id": "1680"
}
我需要更多信息,如姓名、图片、价格等。
您可以使用搜索 API 获取产品的详细信息。
此API将为您提供详细信息的产品:
http://www.dexample.com/index.php/rest/V1/products?
searchCriteria[filter_groups][0][filters][0][field]=category_id&
searchCriteria[filter_groups][0][filters][0][value]=1680&
searchCriteria[filter_groups][0][filters][0][condition_type]=eq
Magento2 的通用搜索 API 是
searchCriteria[filter_groups][<index>][filters][<index>][field]=<field_name>
searchCriteria[filter_groups][<index>][filters][<index>][value]=<search_value>
searchCriteria[filter_groups][<index>][filters][<index>][condition_type]=<operator>
哪里:
field
是一个属性名称。
value
指定要搜索的值。
condition_type
指定条件[例如:eq,finset,like,from,to]