json - 在 Magento2 API 中获取包含更多详细信息的产品列表

标签 json api magento2

我正在开发一个 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/

相关文章:

jquery - $.parseJSON() 在有效对象上返回 null

GitHub API 单一提交不获取所有文件

javascript - 使用 Open Weather API 时如何利用存储在变量中的国家代码?

reactjs - 使用 React 进行 GraphQL 查询时,JSON 意外结束,而 GraphQL 则没有问题

magento - 以编程方式设置自定义客户属性值 Magento 2

magento2 - Magento 2 - 如何循环所有类别并加载类别图像?

javascript - 使用 Angular ng-repeat 在一列中添加多行

c# - 来自数据表和 IList 的嵌套 JSON

javascript - 如何在angularJS中将字符串转换为数组

超出 API 配额