根据商品分类获取前台商品列表页

接口描述:

  • 根据商品分类获取前台商品列表页。

请求 URL:

  • http|https://host/api/v1/goods/method/get.goods.index.list/

请求方式:

  • GET
  • POST

是否授权:

业务参数:

参数名 类型 是否必须 范围值 默认值 示例值 描述
goods_category_id integer egt:0 0 1 商品分类编号
keywords string max:255 华为 商品关键词搜索
is_postage integer in:0,1 1 是否包邮 0=否 1=是
is_integral integer in:0,1 1 是否可积分抵扣 0=否 1=是
shop_price array length:2 [50,100] 商品价格区间
bar_code string max:60 123456 商品条码
brand_id integer gt[]:0 [1,2,3] 商品品牌编号
spec_list array min[]:0 详见备注 商品规格列表
attr_list array min[]:0 详见备注 商品属性列表
page_no integer gt:0 1 1 页码
page_size integer gt:0 15 15 每页数量
order_type string in:asc,desc desc asc 排序方式
order_field string 见附属 A goods_id sales_sum 排序字段

附属 A: in:goods_id,sales_sum,comment_sum,shop_price,create_time

响应参数:

参数名 类型 是否返回 示例值 描述
status integer 200 状态码
message string success 消息信息
data object [] 返回对象
data 类型 是否返回 示例值 描述
filter_menu array [] 筛选后返回的菜单数据
filter_price array [] 当前商品下产生的价格筛选区间
filter_brand array [] 当前商品下的所有品牌
filter_spec array [] 当前商品下可供筛选的规格数据
filter_attr array [] 当前商品下可供筛选的属性数据
filter_cate array [] 关键词搜索后返回有关联的分类数据
items array [] 商品列表项
total_result integer 2 合计计数
filter_menu 类型 是否返回 示例值 描述
text string 颜色:黑色、白色 菜单文本
value array [1,"1","2"] 已筛选的值
param string spec_list 已筛选的参数名
filter_price 类型 是否返回 示例值 描述
text string 5400以内 筛选价格文本
value array [4320,5400] 可筛选的值
filter_brand 类型 是否返回 示例值 描述
text string 小米 筛选品牌文本
value object [] 筛选的品牌对象
value.brand_id integer 24 品牌编号
value.name string 小米 品牌名称
value.phonetic string x 品牌首拼
value.logo string //logo.jpg 品牌LOGO
filter_spec 类型 是否返回 示例值 描述
text string CPU 筛选规格文本
value array [] 可筛选的规格项
value.spec_item_id integer 3 商品规格项编号
value.spec_id integer 2 商品规格编号
value.item_name string I5 商品规格项名
filter_attr 类型 是否返回 示例值 描述
text string 屏幕尺寸 筛选属性文本
value array [] 可筛选的属性项
value.goods_attribute_id integer 3 商品属性编号
value.attr_value string 13.3英寸 属性值
value.sort integer 50 排序值
filter_cate 类型 是否返回 示例值 描述
goods_category_id integer 1 商品分类编号
parent_id integer 0 商品分类上级编号
name string 手机 、 数码 、 通信 商品分类名称
name_phonetic string s 商品分类名称首拼
alias string 数码产品 商品分类别名
alias_phonetic string s 商品分类别名首拼
category_pic string //image.jpg 商品分类图片
category_ioc string  商品分类图标
keywords string 关键词 商品分类关键词
description string 描述 商品分类描述
category_type integer 0 商品分类类型(自定义)
sort integer 50 商品分类排序值
is_navi integer 0 是否显示到导航 0=否 1=是
status integer 1 是否显示 0=否 1=是
children_total integer 8 该分类下关联商品的合计
level integer 0 该分类的层级深度
items 类型 是否返回 示例值 描述
goods_id integer 5 商品编号
name string MateBook 华为 笔记本 商品名称
short_name string MateBook 商品短名称
product_name string XXX促销 商品促销名
brand_id integer 1 商品品牌编号
store_qty integer 200 商品库存
comment_sum integer 0 评价数量
sales_sum integer 0 销售数量
is_postage integer 1 是否包邮 0=收费 1=包邮
market_price number 7000 商品市场价
shop_price number 5400 商品本店价
least_sum integer 1 最少起订量
purchase_sum integer 2 限购数量
attachment array ["//image_1.jpg"] 商品相册
video string //video.mp4 商品短视频
is_recommend integer 1 是否推荐 0=不推 1=推荐
is_new integer 1 是否新品 0=不新 1=新品
is_hot integer 1 是否热卖 0=普通 1=热卖
sort integer 50 排序值

响应示例:

  1. {
  2. "status": 200,
  3. "message": "success",
  4. "data": {
  5. "filter_menu": [
  6. {
  7. "text": "颜色:黑色、白色",
  8. "value": [
  9. 1,
  10. "1",
  11. "2"
  12. ],
  13. "param": "spec_list"
  14. },
  15. {
  16. "text": "屏幕尺寸:13.3英寸",
  17. "value": [
  18. 3,
  19. "13.3英寸"
  20. ],
  21. "param": "attr_list"
  22. }
  23. ],
  24. "filter_price": [
  25. {
  26. "text": "1080以下",
  27. "value": [
  28. 0,
  29. 1080
  30. ]
  31. },
  32. {
  33. "text": "5400以内",
  34. "value": [
  35. 4320,
  36. 5400
  37. ]
  38. }
  39. ],
  40. "filter_brand": [
  41. {
  42. "text": "小米",
  43. "value": {
  44. "brand_id": 24,
  45. "name": "小米",
  46. "phonetic": "x",
  47. "logo": ""
  48. }
  49. },
  50. {
  51. "text": "华为",
  52. "value": {
  53. "brand_id": 23,
  54. "name": "华为",
  55. "phonetic": "h",
  56. "logo": ""
  57. }
  58. }
  59. ],
  60. "filter_spec": [
  61. {
  62. "text": "颜色",
  63. "value": [
  64. {
  65. "spec_item_id": 1,
  66. "spec_id": 1,
  67. "item_name": "黑色"
  68. },
  69. {
  70. "spec_item_id": 2,
  71. "spec_id": 1,
  72. "item_name": "白色"
  73. }
  74. ]
  75. },
  76. {
  77. "text": "CPU",
  78. "value": [
  79. {
  80. "spec_item_id": 3,
  81. "spec_id": 2,
  82. "item_name": "I5"
  83. },
  84. {
  85. "spec_item_id": 4,
  86. "spec_id": 2,
  87. "item_name": "I7"
  88. }
  89. ]
  90. }
  91. ],
  92. "filter_attr": [
  93. {
  94. "text": "屏幕尺寸",
  95. "value": [
  96. {
  97. "goods_attribute_id": 3,
  98. "attr_value": "13.3英寸",
  99. "sort": 50
  100. },
  101. {
  102. "goods_attribute_id": 3,
  103. "attr_value": "15.6英寸",
  104. "sort": 50
  105. }
  106. ]
  107. },
  108. {
  109. "text": "显卡类别",
  110. "value": [
  111. {
  112. "goods_attribute_id": 4,
  113. "attr_value": "独立显卡",
  114. "sort": 40
  115. }
  116. ]
  117. }
  118. ],
  119. "filter_cate": [
  120. {
  121. "goods_category_id": 1,
  122. "parent_id": 0,
  123. "name": "手机 、 数码 、 通信",
  124. "name_phonetic": "s",
  125. "alias": "数码产品",
  126. "alias_phonetic": "s",
  127. "category_pic": "",
  128. "category_ioc": "",
  129. "keywords": "",
  130. "description": "",
  131. "category_type": 0,
  132. "sort": 50,
  133. "is_navi": 0,
  134. "status": 1,
  135. "children_total": 8,
  136. "level": 0
  137. },
  138. {
  139. "goods_category_id": 3,
  140. "parent_id": 0,
  141. "name": "电脑、办公",
  142. "name_phonetic": "d",
  143. "alias": "电脑",
  144. "alias_phonetic": "d",
  145. "category_pic": "",
  146. "category_ioc": "",
  147. "keywords": "",
  148. "description": "",
  149. "category_type": 0,
  150. "sort": 50,
  151. "is_navi": 0,
  152. "status": 1,
  153. "children_total": 7,
  154. "level": 0
  155. }
  156. ],
  157. "items": [
  158. {
  159. "goods_id": 14,
  160. "name": "小米笔记本 白色",
  161. "short_name": "mi",
  162. "product_name": "",
  163. "brand_id": 24,
  164. "store_qty": 200,
  165. "comment_sum": 0,
  166. "sales_sum": 0,
  167. "is_postage": 1,
  168. "market_price": 7000,
  169. "shop_price": 5400,
  170. "least_sum": 1,
  171. "purchase_sum": 2,
  172. "attachment": [
  173. "//image_1.jpg"
  174. ],
  175. "video": "//video.mp4",
  176. "is_recommend": 1,
  177. "is_new": 1,
  178. "is_hot": 1,
  179. "sort": 50
  180. },
  181. {
  182. "goods_id": 13,
  183. "name": "MateBook 华为 笔记本",
  184. "short_name": "MateBook",
  185. "product_name": "XXX促销",
  186. "brand_id": 23,
  187. "store_qty": 200,
  188. "comment_sum": 0,
  189. "sales_sum": 0,
  190. "is_postage": 1,
  191. "market_price": 7000,
  192. "shop_price": 5400,
  193. "least_sum": 1,
  194. "purchase_sum": 2,
  195. "attachment": [
  196. "//image_1.jpg"
  197. ],
  198. "video": "//video.mp4",
  199. "is_recommend": 1,
  200. "is_new": 1,
  201. "is_hot": 1,
  202. "sort": 50
  203. }
  204. ],
  205. "total_result": 2
  206. }
  207. }

备注:

  1. 该接口支持条件搜索,如果不带入业务参数则使用默认值。

  2. 参数keywords支持多个关键词,但只支持空格间隔。如需更高级搜索支持,请自行部署全文索引

  3. 参数filter_brand、filter_spec、filter_attr允许多选筛选。

  4. 参数filter_brand进行筛选比较简单,只需要一个数组即可,而filter_spec、filter_attr筛选前先了解下概念。

    1. 规格举例,规格是一个大的总体,比如『颜色』、『尺寸』、『CPU』,在一个『CPU』下可以有『I5』『I7』等规格项属性也是同等道理。

    2. 根据响应示例返回的值,我们现在进行字段代入。

      1. 规格举例。规格等同于字段spec_id规格项等同于字段spec_item_id
      2. 属性举例。属性等同于字段goods_attribute_id属性项等同于字段attr_value
    3. 筛选参数spec_list

      • A:假设筛选的内容是『CPU』,型号只要『I5』的商品。
        • 字段代入:[$spec_id, $spec_item_id]
        • 实际参数:[2, 3]
      • B:假设筛选的内容是『CPU』,型号只要『I5』或『I7』的商品。
        • 字段代入:[$spec_id, $spec_item_id, $spec_item_id]
        • 实际参数:[2, 3, 4]
      • C:假设现在需要在之前的基础上再进行筛选『颜色』,并且需要『黑色』和『白色』的商品。
        • 字段代入:[[$spec_id, $spec_item_id, $spec_item_id], [$spec_id, $spec_item_id, $spec_item_id]]
        • 实际参数:[[2, 3, 4], [1, 1, 2]]
      • 参数$spec_id的值必须在数组的首位。

        小提示:其实对于举例中的 A 和 B 来说,将实际参数直接组合成多维数组在实际操作中会更加方便,比如实际参数:[2, 3]可以改为[[2, 3]]

    4. 筛选参数attr_list

      • 假设筛选的内容是『屏幕尺寸』,型号只要『15.6英寸』的商品。

        • 字段代入:[$goods_attribute_id, $attr_value]
        • 实际参数:[3, "15.6英寸"]
      • 参数$goods_attribute_id的值必须在数组的首位,其他的方法和spec_list是一样的。