获取可配置产品Magento 2.0 REST Api的所有选项

时间:2016-10-14 06:36:31

标签: php rest magento magento2

当我调用此API时,

{{base_url}}index.php/rest/V1/configurable-products/:sku/options/all

我收到这样的回复,

[
  {
    "id": 9,
    "attribute_id": "93",
    "label": "Color",
    "position": 0,
    "values": [
      {
        "value_index": 15
      },
      {
        "value_index": 16
      },
      {
        "value_index": 17
      }
    ],
    "product_id": 19
  },
  {
    "id": 10,
    "attribute_id": "176",
    "label": "side",
    "position": 1,
    "values": [
      {
        "value_index": 18
      },
      {
        "value_index": 19
      }
    ],
    "product_id": 19
  }
]

但我想要所有这些value_indexes的标签。我可以在一个请求中获得所有这些值

1 个答案:

答案 0 :(得分:1)

有一个用于获取所有标签的pi,

  

{{BASE_URL}} / index.php的/休息/ V1 /产品/属性/:attribute_id /选项

例如:

  

{{BASE_URL}} / index.php的/休息/ V1 /产品/属性/ 93 /选项

将返回

[
  {
    "label": " ",
    "value": ""
  },
  {
    "label": "green",
    "value": "12"
  },
  {
    "label": "yellow",
    "value": "13"
  },
  {
    "label": "red",
    "value": "14"
  }
]