phpmagentomagento2magento-rest-api

Get all options for configurable product Magento 2.0 REST Api


When i call this API,

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

I am getting a response like this,

[
  {
    "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
  }
]

But i want label for all these value_indexes.Could i get all these values in a single request


Solution

  • There is an pi for getting all the labels,

    {{base_url}}/index.php/rest/V1/products/attributes/:attribute_id/options

    Ex:

    {{base_url}}/index.php/rest/V1/products/attributes/93/options

    will return

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