Attribute interfaces and implementations

Adobe Commerce provides the following interfaces to access system attributes and custom attributes defined by the merchant.

InterfaceImplementations

Example usage

Retrieve custom attributes metadata from a customer

The following call returns custom attributes for the logged-in customer. Provide the customer's token in the header section of the query.

Request:

Copied to your clipboard
{
customer {
firstname
lastname
suffix
email
custom_attributes {
code
... on AttributeValue {
value
}
... on AttributeSelectedOptions {
selected_options {
label
value
}
}
}
}
}

Response:

Copied to your clipboard
{
"data": {
"customer": {
"firstname": "John",
"lastname": "Doe",
"suffix": null,
"email": "jdoe@example.com",
"custom_attributes": [
{
"code": "reward_update_notification",
"value": "0"
},
{
"code": "studies",
"selected_options": [
{
"label": "BSc",
"value": "501"
},
{
"label": "MBA",
"value": "502"
}
]
}
]
}
}
}

Filter custom_attributesV2 of a product

The following query returns custom_attributes of a product that have is_comparable enabled.

Request:

Copied to your clipboard
{
products(filter: {sku: {eq: "24-MB02"}})
{
items
{
sku
name
custom_attributesV2(filters: {is_comparable: true})
{
items
{
code
... on AttributeValue {
value
}
... on AttributeSelectedOptions {
selected_options {
label
value
}
}
},
errors {
type
message
}
}
}
}
}

Response:

Copied to your clipboard
{
"data": {
"products": {
"items": [
{
"sku": "24-MB02",
"name": "Fusion Backpack",
"custom_attributesV2": {
"items": [
{
"code": "description",
"value": "<p>With the Fusion Backpack strapped on, every trek is an adventure - even a bus ride to work. That's partly because two large zippered compartments store everything you need, while a front zippered pocket and side mesh pouches are perfect for stashing those little extras, in case you change your mind and take the day off.</p>\n<ul>\n<li>Durable nylon construction.</li>\n<li>2 main zippered compartments.</li>\n<li>1 exterior zippered pocket.</li>\n<li>Mesh side pouches.</li>\n<li>Padded, adjustable straps.</li>\n<li>Top carry handle.</li>\n<li>Dimensions: 18\" x 10\" x 6\".</li>\n</ul>"
},
{
"code": "activity",
"selected_options": [
{
"label": "Yoga",
"value": "17"
},
{
"label": "Hiking",
"value": "27"
},
{
"label": "School",
"value": "29"
}
]
}
],
"errors": []
}
}
]
}
}
}