Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

Fetch attribute values and labels for customAttributeMetadata #87

Closed
cjelger opened this issue Jun 6, 2018 · 3 comments
Closed

Fetch attribute values and labels for customAttributeMetadata #87

cjelger opened this issue Jun 6, 2018 · 3 comments
Assignees

Comments

@cjelger
Copy link

cjelger commented Jun 6, 2018

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

  1. 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
        }
    ]
}]
  1. 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
}
@klimart
Copy link
Contributor

klimart commented Jul 5, 2018

Sample query:

{
  customAttributeMetadata(
    attributes: {
      attribute_code: "color"
      entity_type: "4"
    }
  ) {
    items {
      attribute_code
      entity_type
      attribute_type
      attribute_options {
        value
        label
      }
    }
  }
}

@klimart
Copy link
Contributor

klimart commented Jul 5, 2018

Github Pull Request:
#108

@naydav
Copy link
Contributor

naydav commented Aug 26, 2018

#108

@naydav naydav closed this as completed Aug 26, 2018
magento-engcom-team pushed a commit that referenced this issue May 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants