我正在开发一个 native 应用程序,需要获取基于类别的产品列表。
就像当用户单击某个类别时,我必须显示该类别内的产品列表。
我尝试了一项服务,但它只返回三个字段
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]
关于json - 在 Magento2 API 中获取包含更多详细信息的产品列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50369043/