RoutableInterface attributes

Some Magento entities are “routable”, meaning that they have URLs and can serve as the model for a rendered page. The following implementations of the RoutableInterface allow you to return details in the route query.

RoutableInterface attributes

The RoutableInterface returns the following attributes.

Attribute Data Type Description
redirect_code Int! Contains 0 when there is no redirect error. A value of 301 indicates the URL of the requested resource has been changed permanently, while a value of 302 indicates a temporary redirect
relative_url String The internal relative URL. If the specified URL is a redirect, the query returns the redirected URL, not the original
type UrlRewriteEntityTypeEnum One of PRODUCT, CATEGORY, or CMS_PAGE

Sample Query

The following query returns information about the specified URL key. The query contains multiple fragments so that it can be used for categories, CMS pages, and multiple product types.

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
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
{
  route(url: "teton-pullover-hoodie.html") {
    __typename
    relative_url
    redirect_code
    type
    ... on SimpleProduct {
      sku
      url_key
      uid
      url_rewrites {
        url
        parameters {
          name
          value
        }
      }
    }
    ... on ConfigurableProduct {
      sku
      image {
        label
      }
      uid
      url_key
      url_suffix
      url_rewrites {
        parameters {
          name
          value
        }
      }
      media_gallery {
        url
      }
    }
    ... on CategoryTree {
      uid
      product_count
      canonical_url
      products {
        total_count
        items {
          sku
          uid
        }
      }
    }
    ... on CmsPage {
      content
      content_heading
      meta_title
      meta_keywords
      meta_description
      page_layout
      identifier
      title
      url_key
    }
    ... on GroupedProduct {
      canonical_url
      sku
      items {
        product {
          uid
          url_key
        }
      }
    }
    ... on BundleProduct {
      items {
        sku
        required
        type
        title
        options {
          uid
          is_default
          can_change_quantity
          price_type
          quantity
        }
      }
    }
  }
}

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
{
  "data": {
    "route": {
      "__typename": "ConfigurableProduct",
      "relative_url": "teton-pullover-hoodie.html",
      "redirect_code": 0,
      "type": "PRODUCT",
      "sku": "MH02",
      "image": {
        "label": "Teton Pullover Hoodie"
      },
      "uid": "ODY=",
      "url_key": "teton-pullover-hoodie",
      "url_suffix": ".html",
      "url_rewrites": [
        {
          "parameters": [
            {
              "name": "id",
              "value": "86"
            }
          ]
        },
        {
          "parameters": [
            {
              "name": "id",
              "value": "86"
            },
            {
              "name": "category",
              "value": "16"
            }
          ]
        },
        {
          "parameters": [
            {
              "name": "id",
              "value": "86"
            },
            {
              "name": "category",
              "value": "13"
            }
          ]
        }
      ],
      "media_gallery": [
        {
          "url": "http://example.com/media/catalog/product/cache/3103a735c131a485a1ff51c24439c39b/m/h/mh02-black_main_1.jpg"
        },
        {
          "url": "http://example.com/media/catalog/product/cache/3103a735c131a485a1ff51c24439c39b/m/h/mh02-black_alt1_1.jpg"
        },
        {
          "url": "http://example.com/media/catalog/product/cache/3103a735c131a485a1ff51c24439c39b/m/h/mh02-black_back_1.jpg"
        }
      ]
    }
  }
}