This is a beta release of documentation for Magento 2.4, published for previewing soon-to-be-released functionality. Content in this version is subject to change. Links to the v2.4 code base may not properly resolve until the code is officially released.

Product interface implementations

Magento provides multiple product types, and most of these product types have specialized attributes that are not defined in the ProductInterface.

Product type Implements Has product-specific attributes?
BundleProduct ProductInterface, PhysicalProductInterface, CustomizableProductInterface Yes
ConfigurableProduct ProductInterface, PhysicalProductInterface, CustomizableProductInterface Yes
DownloadableProduct ProductInterface, CustomizableProductInterface Yes
GroupedProduct ProductInterface, PhysicalProductInterface, CustomizableProductInterface Yes
SimpleProduct ProductInterface, PhysicalProductInterface, CustomizableProductInterface No
VirtualProduct ProductInterface, CustomizableProductInterface No

Query for product-specific attributes

To return attributes that are specific to a product type, append a structure similar to the following to the end of the Products output object:

1
2
3
4
5
6
7
... on <ProductType> {
  items{
    <ProductType-attribute1>
    <ProductType-attribute2>
    ...
    }
  }

For example, to return GroupedProduct attributes, construct your query like this:

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
{
  products(filter:
    {sku: {eq: "24-WG085_Group"}}
  )
  {
    items {
      id
      name
      sku
      __typename
      ... on GroupedProduct {
        items{
          qty
          position
          product{
            sku
            name
            __typename
            url_key
          }
        }
      }
    }
  }
}
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
{
  "data": {
    "products": {
      "items": [
        {
          "id": 45,
          "name": "Set of Sprite Yoga Straps",
          "sku": "24-WG085_Group",
          "__typename": "GroupedProduct",
          "items": [
            {
              "qty": 0,
              "position": 0,
              "product": {
                "sku": "24-WG085",
                "name": "Sprite Yoga Strap 6 foot",
                "__typename": "SimpleProduct",
                "url_key": "sprite-yoga-strap-6-foot"
              }
            },
            {
              "qty": 0,
              "position": 1,
              "product": {
                "sku": "24-WG086",
                "name": "Sprite Yoga Strap 8 foot",
                "__typename": "SimpleProduct",
                "url_key": "sprite-yoga-strap-8-foot"
              }
            },
            {
              "qty": 0,
              "position": 2,
              "product": {
                "sku": "24-WG087",
                "name": "Sprite Yoga Strap 10 foot",
                "__typename": "SimpleProduct",
                "url_key": "sprite-yoga-strap-10-foot"
              }
            }
          ]
        }
      ]
    }
  }
}