This repository was archived by the owner on Dec 19, 2019. It is now read-only.
This repository was archived by the owner on Dec 19, 2019. It is now read-only.
Fetch attribute values and labels for customAttributeMetadata #87
Closed
Description
It would be really useful to be able to get all the possible values and labels for "select" attributes. For example with the following request there is currently no way to get all the values and labels for the "color" attribute.
{
customAttributeMetadata(
attributes: {
attribute_code: "color"
entity_type: "4"
}
) {
items {
attribute_code
entity_type
attribute_type
}
}
}
Acceptance criteria
- The service response should be restructured and extended as follows:
[{
"__implements": "EavAttributeInterface",
"__typename": "DropdownEavAttribute",
"entity_type": "catalog_product",
"render_metadata": {
"__typename": "EavAttributeRenderMetadata",
"input_type": "dropdown",
"value_type": "Int"
},
"attribute_code": "color",
"options": [
{
"__typename": "EavAttributeDropDownOptionMetadata",
"label": "Red",
"value": 4 // Derived from "value_type" above (just an example of the utility)"
},
{
"label": "Blue",
"value": 5
}
]
}]
- Changes should be covered with web API functional tests. See \Magento\GraphQl\Catalog\ProductViewTest::testQueryAllFieldsSimpleProduct as an example.
Alternative options that were considered:
It would be great to have the possibility to extend the response with something like:
{
"data": {
"customAttributeMetadata": {
"items": [
{
"attribute_code": "color",
"entity_type": "4",
"attribute_type": "Int"
"options": [
{
"value": "1",
"label": "Green"
},
{
"value": "2",
"label": "Red"
}
]
}
]
}
}
}
Another alternative could be to be able to get the label for the attributes of ProductInterface
. For example, color
currently returns an Int
, but it would be great to also be able to get the label for the value, so something like:
color {
value
label
}