Index a Salesforce Commerce Cloud instance
Index a Salesforce Commerce Cloud instance
This article explains how to create a Coveo source to index a Salesforce Commerce Cloud instance. The indexed data can be used in a Coveo-powered search interface built within the Salesforce Composable Storefront.
Prerequisites
Make sure that you have:
-
data in your Salesforce Commerce Cloud instance.
-
access to the B2C Account Manager (also known as Demandware). To get access, you have to contact an account administrator within your organization.
Index a Salesforce Commerce Cloud
-
Log in to the SLAS Admin UI by using your own short code.
https://<SHORT-CODE>.api.commercecloud.salesforce.com/shopper/auth-admin/v1/ui/
-
Once logged in, you can see the
Client ID
andSecret
fields. Copy the values of these fields and store them somewhere locally. -
To create a token for indexing data, you need to make a POST request to the
getAccessToken
endpoint of the Shopper Login API.You can do it by using the Postman application.
-
Use the
Client ID
andSecret
values from the previous steps asLogin
andPassword
respectively. -
Specify
Basic Auth
as the Authentication Type. -
Substitute your shortCode and organizationId
https://{shortCode}.api.commercecloud.salesforce.com/shopper/auth/v1/organizations/{organizationId}/oauth2/token
You will receive an SLAS token in a response.
The SLAS token is valid only for 30 minutes. Once it expires, you have to create a new one.
-
-
Go to your Coveo organization and add a Generic REST API cloud source. On the Configuration tab, expand the Content to include section and paste the following JSON.
{ "Services": [ { "Paging": { "PageSize": 200, "offset": 0, "OffsetType": "item", "Parameters": { "Limit": "limit", "Offset": "offset" } }, "Url": "https://{shortCode}.api.commercecloud.salesforce.com/",
"Endpoints": [ { "Headers": { "Authorization": "Bearer @ApiKey"
}, "Path": "/search/shopper-search/v1/organizations/{organizationId}/product-search",
"QueryParameters": { "q": "storefront-catalog-m-en", "limit": "200",
"siteId": "RefArch"
}, "Method": "GET", "ItemType": "products", "ItemPath": "hits", "Uri": "https://zzte-053.sandbox.us02.dx.commercecloud.salesforce.com/s/RefArch/%[productName]/%[productId].html",
"ClickableUri": "https://zzte-053.sandbox.us02.dx.commercecloud.salesforce.com/s/RefArch/%[productName]/%[productId].html", "Title": "%[productName] %[productId]", "ModifiedDate": "%[modified_time]", "Body": "%[productName] %[price] %[currency]", "Metadata": { "ec_name": "%[productName]", "ec_price": "%[price]", "ec_productid": "%[productId]", "ec_colors": "%[variationAttributes[?(@.id=='color')].values[:].name]" }, "SubQueries": [ { "Method": "GET", "Path": "/product/shopper-products/v1/organizations/f_ecom_zzte-053/products/%[coveo_parent.ec_productid]", "Headers": { "Authorization": "Bearer @ApiKey" }, "QueryParameters": { "siteId": "RefArch" }, "metadata": { "ec_brand": "%[brand]", "ec_description": "%[longDescription]", "ec_shortdesc": "%[shortDescription]", "ec_category_code": "%[primaryCategoryId]" } } ], "SubItems": [ { "ItemPath": "variationAttributes", "ItemType": "variations", "image": "%[coveo_parent.raw.image.link]", "Uri": "https://%[coveo_parent.raw.productId]/%[id]/%[name]", "ClickableUri": "https://%[coveo_parent.raw.productName]/%[id]", "Title": "%[coveo_parent.raw.productName] %[id]", "ModifiedDate": "%[modified_time]", "Body": "%[coveo_parent.raw.productName] %[coveo_parent.raw.price] %[coveo_parent.raw.currency] %[name]" } ] } ] } ] }
Use your short code. Specify the SLAS token from the previous step. Use your organizationId. The maximum number of products to retrieve. This is a limit set by the Salesforce Shoppers APIs. Substitute your siteId. Use your Business Manager URL and siteId in this and the next fields. -
Click Add and build source.
On the Sources (platform-ca | platform-eu | platform-au) page, you can review the progress of your source addition or modification.
Once the source is built or rebuilt, you can review its content in the Content Browser.