Index SAP Commerce Using the SAP OData2 GET API

This article explains how to use the Coveo Generic REST API connector to index SAP Commerce Cloud [1] catalog data exposed through an Integration API endpoint.

This is a pull approach to indexing content. If you have a way to extract your content and want to push it to Coveo instead, see Index commerce catalog content.

The examples provided in this article are for a simple use case that involves products only. Your final structure will vary depending on how you set up your catalog within SAP.

To get OData2 representation through this API, see The OData2 GET API.

Prerequisites

To index your commerce content, you need a Coveo organization. Coveo lets you create a source which is the bridge to your commerce data.

If you have never used the Cloud Platform before, log in now.

  • Contact your sales representative to enable Coveo for Commerce features in your organization.

  • You can review your Coveo organization license limits.

  • Ensure that you set the Required Privileges for your commerce organization.

Expose Your SAP Catalog

SAP Commerce Cloud’s Integration API Module exposes a set of interfaces used for data integration. You’ll need to create a Product Integration Object to expose your products. Here are a few leading practices to consider when creating the product integration object:

This is an example of what Coveo receives when calling the API:

Example response payload
{
  "d": {
    "results": [
        {
            "__metadata": {
                "id": "https://api.acmestore.com/odata2webservices/CoveoInboundProduct/Products",
                "uri": "https://api.acmestore.com/odata2webservices/CoveoInboundProduct/Products",
                "type": "HybrisCommerceOData.Product"
                },
            "code": "137220",
            "name": "Camcordertape DV 60min (2)",
            "manufacturerAID": "2DVM60PR-BT",
            "manufacturerName": "Sony",
            "case_color": "red",
            "description": "<br/><br/>Perfect digital picture with a resolution that exceeds 500 lines.<br/><br/>Infinite range of possibilities to edit and share your videos.<br/><br/>Possibility to record up to 50% more in LP mode.<br/><br/>Cleaning Tape: DVM12CLD.<br/><br/>",

            "integrationKey": "Online|electronicsProductCatalog|137220",
            "stockLevels": {
                "__deferred": {
                "uri": "https://api.acmestore.com/odata2webservices/CoveoInboundProduct/Products"
                }
            },
...
        }
    ],
"__next": "https://api.acmestore.com/odata2webservices/CoveoInboundProduct/Products?$filter=catalogVersion%2FintegrationKey%20eq%20%27Online%7CelectronicsProductCatalog%27&$top=1&$skiptoken=2"
    }
}
//...

Fetch Catalog Content in Coveo

To index data accessible through an exposed REST API, you must create a Generic REST source. The attributes from your API are leveraged by the REST configuration and it will take a corresponding field for them to end up in your indexed catalog.

  • Complete the authentication section for the method used by the API you want to retrieve content from.

  • Create fields in the index for each metadata you want to retrieve with the Generic REST API source.

  • Ensure that your source maps all the fields you want to populate. If a field doesn’t have a mapping, you must create one.

You can adapt the values in function with your API response as each use case will be different.

{
  "Services": [
    {
      "Url": "<YOUR_API_URL>",(1)
      "Endpoints": [
        {
          "Path": "<YOUR_PATH>",(2)
          "Method": "GET",
          "QueryParameters": {
            "$filter": "<YOUR_FILTER>"(3)
          },
          "ItemType": "Product",
          "ItemPath": "d.results",
          "Uri": "%[coveo_url]/products/%[code]",
          "ClickableUri": "%[coveo_url]/products/%[code]",
          "Name": "%[name]",
          "Body": "%[description]",
          "ModifiedDate": "%[updated]",
          "Headers": {
            "Accept": "application/json"
          },
          "Metadata": {
            "code": "%[code]",
            "brand": "%[manufacturerName]",
            "color": "%[case_color]"
          },
          "Paging": {
            "PageSize": 10,
            "OffsetStart": 0,
            "OffsetType": "item",
            "Parameters": {
              "Limit": "$top",
              "Offset": "$skip"
            }
          }
        }
      ]
    }
  ]
}
//...
Value Description Example

<YOUR_API_URL>

The URL of your SAP Commerce Cloud OData2 GET API.

https://api.acmestore.com/odata2webservices/CoveoInboundProduct

<YOUR_PATH>

The specific resource path on your API.

/Products

<YOUR_FILTER>

Expression filtering the products that are returned. Must be URL encoded.

catalogVersion%2FintegrationKey%20eq%20%27Online%7CelectronicsProductCatalog%27

Refer to Generic REST API Source JSON Configuration Examples for more configuration examples.

Once you have rebuilt your source, you can inspect the items with the Content Browser.

What’s Next?

Once you have the data in the index, create a Coveo commerce catalog to define the structure of your commerce-related items. In other words, you will establish the relationship between the items you’ve indexed in the previous step by identifying which items are products, variants, and availability channels.


1. SAP Commerce Cloud previously called Hybris.
What's Next for Me?