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


Get all options for configurable product Magento 2.0 REST Api

当我调用这个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标签。我可以得到所有这些值在一个单一的请求

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

{{base_url}}/index . php/休息/V1/产品/属性/:attribute_id/选择

,

{{base_url}}/index . php/rest/V1/产品/属性/93/选项

将返回

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

您可以使用此端点在单个请求中获取多个属性集/rest/V1/products/attributes

的例子:

{domain}/rest/V1/products/attributes?search_criteria[filter_groups][0][filters][0][field]=attribute_id&search_criteria[filter_groups][0][filters][0][value]=93,138&search_criteria[filter_groups][0][filters][0][condition_type]=in

反应:

    "items": [
        {
            "is_wysiwyg_enabled": false,
            "is_html_allowed_on_front": false,
            "used_for_sort_by": false,
            "is_filterable": true,
            "is_filterable_in_search": false,
            "is_used_in_grid": true,
            "is_visible_in_grid": false,
            "is_filterable_in_grid": true,
            "position": 0,
            "apply_to": [
                "simple",
                "virtual",
                "configurable"
            ],
            "is_searchable": "1",
            "is_visible_in_advanced_search": "1",
            "is_comparable": "1",
            "is_used_for_promo_rules": "0",
            "is_visible_on_front": "0",
            "used_in_product_listing": "0",
            "is_visible": true,
            "scope": "global",
            "attribute_id": 93,
            "attribute_code": "color",
            "frontend_input": "select",
            "entity_type_id": "4",
            "is_required": false,
            "options": [
                {
                    "label": " ",
                    "value": ""
                },
                {
                    "label": "blue",
                    "value": "8"
                },
                {
                    "label": "red",
                    "value": "9"
                },
                {
                    "label": "black",
                    "value": "10"
                },
                {
                    "label": "white",
                    "value": "11"
                }
            ],
            "is_user_defined": true,
            "default_frontend_label": "Color",
            "frontend_labels": [],
            "backend_type": "int",
            "source_model": "Magento''Eav''Model''Entity''Attribute''Source''Table",
            "default_value": "",
            "is_unique": "0",
            "validation_rules": []
        },
        {
            "is_wysiwyg_enabled": false,
            "is_html_allowed_on_front": true,
            "used_for_sort_by": false,
            "is_filterable": false,
            "is_filterable_in_search": false,
            "is_used_in_grid": true,
            "is_visible_in_grid": true,
            "is_filterable_in_grid": true,
            "position": 0,
            "apply_to": [],
            "is_searchable": "0",
            "is_visible_in_advanced_search": "0",
            "is_comparable": "0",
            "is_used_for_promo_rules": "0",
            "is_visible_on_front": "0",
            "used_in_product_listing": "0",
            "is_visible": true,
            "scope": "global",
            "attribute_id": 138,
            "attribute_code": "simple_size",
            "frontend_input": "select",
            "entity_type_id": "4",
            "is_required": true,
            "options": [
                {
                    "label": " ",
                    "value": ""
                },
                {
                    "label": "small",
                    "value": "12"
                },
                {
                    "label": "medium",
                    "value": "13"
                },
                {
                    "label": "large",
                    "value": "14"
                }
            ],
            "is_user_defined": true,
            "default_frontend_label": "simple_size",
            "frontend_labels": [
                {
                    "store_id": 1,
                    "label": "Size"
                }
            ],
            "backend_type": "int",
            "source_model": "Magento''Eav''Model''Entity''Attribute''Source''Table",
            "default_value": "",
            "is_unique": "0",
            "validation_rules": []
        }
    ],
    "search_criteria": {
        "filter_groups": [
            {
                "filters": [
                    {
                        "field": "attribute_id",
                        "value": "93,138",
                        "condition_type": "in"
                    }
                ]
            }
        ]
    },
    "total_count": 2
}