Adobe Commerce only. Learn more.

attributeMetadata query

The attributeMetadata query returns a list of product attribute codes that can be used for sorting or filtering in a productSearch query. The query response can include the attribute name, display label, and a Boolean value that indicates if the attribute has a numeric value.

Syntax

attributeMetadata: AttributeMetadataResponse!

Required headers

You must specify the following HTTP headers to run this query. GraphQL Support describes each of these headers.

  • Magento-Environment-Id
  • Magento-Website-Cod
  • Magento-Store-Code
  • Magento-Store-View-Code
  • X-Api-Key

Example usage

The following query returns details about all product attributes that can be used to define the sorting order or as a filter in a productSearch query.

Request:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
  attributeMetadata{
    sortable {
      attribute
      label
      numeric
    }
    filterableInSearch  {
      attribute
      label
      numeric
    }
  }
}

Response:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
{
  "extensions": {
    "request-id": "5Kd6pzYc02PlHIbbmNDTff3VaXF0EnYf"
  },
  "data": {
    "attributeMetadata": {
      "sortable": [
        {
          "attribute": "name",
          "label": "Product Name",
          "numeric": false
        },
        {
          "attribute": "price",
          "label": "Price",
          "numeric": true
        },
        {
          "attribute": "position",
          "label": "position",
          "numeric": true
        }
      ],
      "filterableInSearch": [
        {
          "attribute": "categoryIds",
          "label": "categoryIds",
          "numeric": false
        },
        {
          "attribute": "collar",
          "label": "Collar",
          "numeric": false
        },
        {
          "attribute": "visibility",
          "label": "visibility",
          "numeric": false
        },
        {
          "attribute": "activity",
          "label": "Activity",
          "numeric": false
        },
        {
          "attribute": "gender",
          "label": "Gender",
          "numeric": false
        },
        {
          "attribute": "size",
          "label": "Size",
          "numeric": false
        },
        {
          "attribute": "price",
          "label": "price",
          "numeric": true
        },
        {
          "attribute": "sleeve",
          "label": "Sleeve",
          "numeric": false
        },
        {
          "attribute": "eco_collection",
          "label": "Eco Collection",
          "numeric": false
        },
        {
          "attribute": "categories",
          "label": "categories",
          "numeric": false
        },
        {
          "attribute": "climate",
          "label": "Climate",
          "numeric": false
        },
        {
          "attribute": "sku",
          "label": "sku",
          "numeric": false
        }
      ]
    }
  }
}

Output fields

The AttributeMetadataResponse return object can contain the following fields:

Field Data Type Description
filterableInSearch FilterableInSearchAttribute An array of product attributes that can be used for filtering in a productSearch query
sortable SortableAttribute An array of product attributes that can be used for sorting in a productSearch query

FilterableInSearchAttribute data type

The FilterableInSearchAttribute data type can contain the following fields:

Field Data Type Description
attribute String! The unique identifier for an attribute code. This value should be in lowercase letters and without spaces
label String The display name assigned to the attribute
numeric Boolean Indicates whether this attribute has a numeric value, such as a price or integer

SortableAttribute data type

The SortableAttribute data type can contain the following fields:

Field Data Type Description
attribute String! The unique identifier for an attribute code. This value should be in lowercase letters and without spaces
label String The display name assigned to the attribute
numeric Boolean Indicates whether this attribute has a numeric value, such as a price or integer