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.

Downloadable product data types

The DownloadableProduct data type implements ProductInterface and CustomizableProductInterface. As a result, attributes that are specific to downloadable products can be used when performing a products query.

Downloadable product

The DownloadableProduct object contains the following attributes:

Attribute Type Description
downloadable_product_links [DownloadableProductLinks] An array containing information about the links for this downloadable product
downloadable_product_samples [DownloadableProductSamples] An array containing information about samples of this downloadable product
links_purchased_separately Int A value of 1 indicates that each link in the array must be purchased separately
links_title String The heading above the list of downloadable products

DownloadableProductSamples object

The DownloadableProductSamples object contains the following attributes:

Attribute Type Description
id Int Deprecated. This attribute is not applicable for GraphQL
sample_file String Deprecated. Use sample_url instead
sample_type DownloadableFileTypeEnum Deprecated. Use sample_url instead
sample_url String The URL to the downloadable sample
sort_order Int A number indicating the sort order
title String The display name of the sample

The DownloadableProductLinks object contains the following attributes:

Attribute Type Description
id Int Deprecated. This information should not be exposed on frontend
is_shareable Boolean Deprecated. This attribute is not applicable for GraphQL
link_type DownloadableFileTypeEnum Deprecated. Use sample_url instead
number_of_downloads Int Deprecated. This attribute is not applicable for GraphQL
price Float The price of the downloadable product
sample_file String Deprecated. Use sample_url instead
sample_type DownloadableFileTypeEnum Deprecated. Use sample_url instead
sample_url String The URL to the downloadable sample
sort_order Int A number indicating the sort order
title String The display name of the link

Example usage

Add the following inline fragment to the output section of your products query to return information specific to downloadable products:

1
2
3
4
5
... on DownloadableProduct {
  items {
   <attributes>
  }
}

The following query returns information about downloadable product 240-LV04, which is defined in the sample data.

Request:

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
{
  products(filter: { sku: { eq: "240-LV04" } }) {
    items {
      id
      name
      sku
      __typename
      price_range{
        minimum_price{
          regular_price{
            value
            currency
          }
        }
      }
      ... on DownloadableProduct {
        links_title
        links_purchased_separately

        downloadable_product_links {
          sample_url
          sort_order
          title
          price
        }
        downloadable_product_samples {
          title
          sort_order
          sample_url
        }
      }
    }
  }
}

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
{
  "data": {
    "products": {
      "items": [
        {
          "id": 47,
          "name": "Beginner's Yoga",
          "sku": "240-LV04",
          "__typename": "downloadable",
          "price_range": {
            "minimum_price": {
              "regular_price": {
                "value": 6,
                "currency": "USD"
              }
            }
          },
          "links_title": "Downloads",
          "links_purchased_separately": 0,
          "downloadable_product_links": [
            {
              "sample_url": null,
              "sort_order": 1,
              "title": "Beginner's Yoga",
              "price": 6
            }
          ],
          "downloadable_product_samples": [
            {
              "title": "Trailer #1",
              "sort_order": 1,
              "sample_url": "/l/u/luma_background_-_model_against_fence_4_sec_.mp4"
            },
            {
              "title": "Trailer #2",
              "sort_order": 1,
              "sample_url": "/l/u/luma_background_-_model_against_fence_4_sec_.mp4"
            },
            {
              "title": "Trailer #3",
              "sort_order": 1,
              "sample_url": "/l/u/luma_background_-_model_against_fence_4_sec_.mp4"
            }
          ]
        }
      ]
    }
  }
}