External references with commercetools

Overview

You can integrate External references with commercetools. With External references you can retrieve commercetools products and product categories through the Contentful GraphQL API. This way, you can get all the information you need in a single API call to create a great customer experience.

Enable External references for commercetools 

To enable External references for commercetools:

  1. Configure your commercetools project. 

  2. Log in to the Contentful web app.

  3. Install the commercetools app in the Contentful web app. 

  4. Configure the credentials needed inside the Contentful commercetools App configuration screen. For more information on how to set up the credentials, see step 2 of the commercetools page. 

  5. Navigate to the “Content model” tab and select the content type you want to retrieve data from with External references.

  6. Click +Add field and add a new field of type “Text”.

  7. In the "Appearance" section, under "Choose how this field should be displayed", select commercetools

  8. Select the Resolve content on delivery check box.

  9. Click Confirm.

  10. Save your changes.

Query commercetools data in Contentful using the GraphQL API

To query Shopify data in Contentful using the GraphQL API:

  1. Open your preferred GraphQL client or use an online IDE. You can also use our GraphQL Playground app.

  2. Insert the following GraphQL query as an example, replacing "ENTRY_ID" with the ID of the product you want to query:

    markdown
    {
      topicProduct(id: "ENTRY_ID") {
        sys {
          id
          spaceId
        }
        thirdPartyReferenceFieldName
        thirdPartyReferenceFieldName_data {
          title
          description
        }
      }
    }
    

  3. Run the query.

For more information on adjusting your GraphQL API queries and possible errors, see the technical External references and GraphQL API documentation.

Was this helpful?
add-circle arrow-right remove style-two-pin-marker subtract-circle remove