close

Filter

loading table of contents...

Headless Server Developer Manual / Version 2404

Table Of Contents

7.4 References to Products and Categories

The Headless Server does not provide access to purely commerce data directly. Instead the schema includes the types CategoryRef and ProductRef, which represent a link to a category or a product respectively. Links from CMS contents to commerce objects can be accessed via a productRef for content of type CMExternalProduct or categoryRef for content of type CMExternalChannel.

{
  content {
    content(id: "3240") {
      ...on CMExternalProduct {
        repositoryPath
        productRef {
          externalId
          locale
          storeId
        }
      }
    }
  }
}

The CategoryRef can be used to be resolved externally into a category, the ProductRef can be resolved into a product. This can be done via schema stitching or directly within a headless client application.

For example a product list query would look like this:

{
    content {
    content(id: "850") {
      ... on CMProductList {
        items {
          ... on CMTeasable {
            teaserTitle
          }
          ... on CommerceRef {
            externalId
            storeId
            locale
          }
        }
      }
    }
  }
}

And here the data retrieved:

{
  "data": {
    "content": {
      "content": {
        "items": [
          {
            "externalId": "AuroraWMDRS-1",
            "storeId": "1",
            "locale": "en-US"
          },
          {
            "externalId": "AuroraWMDRS-4",
            "storeId": "1",
            "locale": "en-US"
          },
          {
            "teaserTitle": "Find your personal style"
          },
          {
            "teaserTitle": "Editorial Blog"
          },
          {
            "externalId": "AuroraWMDRS-23",
            "storeId": "1",
            "locale": "en-US"
          },
          {
            "externalId": "AuroraWMDRS-24",
            "storeId": "1",
            "locale": "en-US"
          }
        ]
      }
    }
}

A CommerceRef includes the data needed to load the product itself from the commerce system again.

Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.