> ## Documentation Index
> Fetch the complete documentation index at: https://docs.occtoo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# commercetools

## Introduction

Occtoo provides a pre-built formatter that transfers product, variant, category, and attribute data from Occtoo to commercetools.

Changes are propagated automatically, and the configuration options make it easy to tailor the integration to your needs.

Occtoo Studio gives you full control over what is transferred: use segments to select the content, and choose which languages and attributes to include.

## About commercetools

commercetools is a cloud-based headless commerce platform that provides APIs to power e-commerce sales and similar functions for large businesses.

Read more at [commercetools.com](https://commercetools.com).

## Data flow

The data exposed by an Occtoo destination is transferred by the formatter and pushed to an import container in commercetools. The product flow is mandatory; the category flow is optional.

The formatter runs every hour and checks for deltas, which are then sent to commercetools. You can also trigger a full run manually when needed. Updates are pushed to a commercetools import container, which imports them asynchronously so that large numbers of updates can be processed. You can follow the progress of an import in the Merchant Center.

<img src="https://mintcdn.com/occtoo/Rffi00S7HgnZZeFr/images/integrations/formatters/commercetools_overview-8963081a1f08ec93d36317d9c1cf5ef2.jpg?fit=max&auto=format&n=Rffi00S7HgnZZeFr&q=85&s=e75da637fe82702b658c7fb690a8501b" alt="Overview of the data transfer to commercetools" width="4162" height="1501" data-path="images/integrations/formatters/commercetools_overview-8963081a1f08ec93d36317d9c1cf5ef2.jpg" />

## Installation and setup

### Prerequisites

* Access to the commercetools Merchant Center
* Access to the source code

### Get the code

Request the code from [developer@occtoo.com](mailto:developer@occtoo.com).

### Register an API client in commercetools

Register an API client in commercetools by going to **Settings > Developer settings** and selecting **Create new API client**. Make sure to select the scopes required by the formatter, then copy all the values shown in the API client details — they are only displayed once.

Add the values to the following formatter settings:

* `CommercetoolsImportClient__ClientId`
* `CommercetoolsImportClient__ClientSecret`
* `CommercetoolsImportClient__AuthorizationBaseAddress`
* `CommercetoolsImportClient__Scope`
* `CommercetoolsImportClient__ProjectKey`
* `CommercetoolsImportClient__ApiBaseAddress`

<Info>
  The values for `CommercetoolsImportClient__AuthorizationBaseAddress` and `CommercetoolsImportClient__ApiBaseAddress` must end with a slash (`/`).
</Info>

<img src="https://mintcdn.com/occtoo/Rffi00S7HgnZZeFr/images/integrations/formatters/commercetools_apiClient-8348e9c411f3e44e00893ebf40e63d9e.png?fit=max&auto=format&n=Rffi00S7HgnZZeFr&q=85&s=2c5f4d6b9d9f79e415a31f145fc87a02" alt="Registering an API client in commercetools" width="1676" height="985" data-path="images/integrations/formatters/commercetools_apiClient-8348e9c411f3e44e00893ebf40e63d9e.png" />

### Endpoints

#### Products

The product flow is mandatory, so you need to provide an endpoint for product and product variant data. Add the URL of the product endpoint to the following setting:

* `DestinationSettings__ProductUrl`

The endpoint must expose these properties:

* productName — Localized text
* productSlug — Localized text
* productId — Text

The following properties are recommended:

* productCategories — List
* sku — Text
* productDescription — Text
* productType — Text
* productMetaTitle — Localized text
* productKeywords — Localized text
* isMasterVariant — Boolean

<img src="https://mintcdn.com/occtoo/Rffi00S7HgnZZeFr/images/integrations/formatters/commercetools_products-5d1cb7fb987160bc6c6188c3ce952165.png?fit=max&auto=format&n=Rffi00S7HgnZZeFr&q=85&s=ec2b865b34d21dcaa2b42a224d3bb128" alt="Product properties in commercetools" width="3532" height="1580" data-path="images/integrations/formatters/commercetools_products-5d1cb7fb987160bc6c6188c3ce952165.png" />

#### Categories

The category flow is optional and requires a separate endpoint for the categories. If you use it, add the URL to the following setting:

* `DestinationSettings__CategoriesUrl`

If you omit this setting, no category data is transferred. The endpoint must expose these properties:

* name — Localized text
* slug — Localized text

The following properties are recommended:

* description — Localized text
* parent — Text
* externalId — Text
* metaTitle — Localized text
* metaDescription — Localized text
* metaKeywords — Localized text
* orderHint — Text

<Info>
  The value of orderHint must be between 0 and 1.
</Info>

<img src="https://mintcdn.com/occtoo/Rffi00S7HgnZZeFr/images/integrations/formatters/occtoo_category-cadc34850c62e1d820c91f7afca65647.png?fit=max&auto=format&n=Rffi00S7HgnZZeFr&q=85&s=66c333ab3adabf44261f04c969f61018" alt="Category properties in Occtoo" width="1257" height="605" data-path="images/integrations/formatters/occtoo_category-cadc34850c62e1d820c91f7afca65647.png" />

<img src="https://mintcdn.com/occtoo/Rffi00S7HgnZZeFr/images/integrations/formatters/commercetools_categories-652fbfc7b4cf8c928626fb9525587645.png?fit=max&auto=format&n=Rffi00S7HgnZZeFr&q=85&s=69d5df3cd424a8a25107f6132c1a7ba6" alt="Categories in commercetools" width="1675" height="665" data-path="images/integrations/formatters/commercetools_categories-652fbfc7b4cf8c928626fb9525587645.png" />

### Register an application in Occtoo

[Register an application](/guides/studio/destinations/register-an-application) in Occtoo Studio and save its credentials in the configuration file for the formatter. Add the following settings:

* `ApiClientCredentials__ClientId`
* `ApiClientCredentials__ClientSecret`
* `ApiClientCredentials__TokenAuthUrl`

<img src="https://mintcdn.com/occtoo/Rffi00S7HgnZZeFr/images/integrations/formatters/occtoo_application-46482c83037ef93889eb021e977c0b95.png?fit=max&auto=format&n=Rffi00S7HgnZZeFr&q=85&s=53ccb4647054a89b510148be95a034d6" alt="Registering an application in Occtoo" width="1563" height="873" data-path="images/integrations/formatters/occtoo_application-46482c83037ef93889eb021e977c0b95.png" />

### Product type

Create a product type in commercetools to assign to all products, then add its name to the `CommercetoolsSettings__ProductTypeName` setting in the configuration file for the formatter.

<img src="https://mintcdn.com/occtoo/Rffi00S7HgnZZeFr/images/integrations/formatters/commercetools_productType-9f41f3ec1ce665ed66e5e8baf01fb894.png?fit=max&auto=format&n=Rffi00S7HgnZZeFr&q=85&s=dca463b7a9c449f427d57e630e8758c6" alt="Product types in commercetools" width="1794" height="679" data-path="images/integrations/formatters/commercetools_productType-9f41f3ec1ce665ed66e5e8baf01fb894.png" />

### Languages

The languages configured for the destination should match the languages configured in the Merchant Center. Add the list of outbound languages to the configuration file for the formatter, with one row per language. For example:

```json theme={null}
"CommercetoolsSettings__Languages__[0]": "en",
"CommercetoolsSettings__Languages__[1]": "en-US",
"CommercetoolsSettings__Languages__[2]": "de-DE"
```

<img src="https://mintcdn.com/occtoo/Rffi00S7HgnZZeFr/images/integrations/formatters/commercetools_languages-ae2922abfb2c5f86f3adea26d5d68df9.png?fit=max&auto=format&n=Rffi00S7HgnZZeFr&q=85&s=8153717a736046dd400a0f6107536c03" alt="Languages in commercetools" width="1734" height="746" data-path="images/integrations/formatters/commercetools_languages-ae2922abfb2c5f86f3adea26d5d68df9.png" />

<img src="https://mintcdn.com/occtoo/Rffi00S7HgnZZeFr/images/integrations/formatters/occtoo_languages-ceec4458ec45559036343f41c602b472.png?fit=max&auto=format&n=Rffi00S7HgnZZeFr&q=85&s=56813eba26208257aa7b44bf39ffa557" alt="Languages in Occtoo" width="815" height="680" data-path="images/integrations/formatters/occtoo_languages-ceec4458ec45559036343f41c602b472.png" />

### Import container

Import containers are created automatically and can be viewed in the Merchant Center. Use them to follow ongoing imports and to get information about any failures.

<img src="https://mintcdn.com/occtoo/Rffi00S7HgnZZeFr/images/integrations/formatters/commercetools_import_container-c54fccdbf753303f7d6f18417dcc31e7.png?fit=max&auto=format&n=Rffi00S7HgnZZeFr&q=85&s=aa8f9e62a51db847831c51f9853ab2b4" alt="Import container in commercetools" width="1810" height="660" data-path="images/integrations/formatters/commercetools_import_container-c54fccdbf753303f7d6f18417dcc31e7.png" />

### Attributes

Create the attributes in commercetools under the product type specified in the previous step, and set each attribute key to match the property identifier in Occtoo. For list values in commercetools, the values must be predefined before they can be used.

Add the attributes you want to transfer to the configuration file for the formatter and specify the commercetools attribute type for each one. For example:

```json theme={null}
"CommercetoolsSettings__AttributeDictionary__WashingTemperature": "Number",
"CommercetoolsSettings__AttributeDictionary__IsWashable": "Boolean",
"CommercetoolsSettings__AttributeDictionary__DetailedDescription": "LocalizedText",
"CommercetoolsSettings__AttributeDictionary__Color": "EnumList"
```

The supported attribute types are:

* Boolean
* Text
* LocalizedText
* Number
* DateTime
* Date
* Time
* EnumList
* LocalizedList

### Product publishing

To publish products or product variants automatically when they are transferred to commercetools, set either of these settings to `true`:

* `CommercetoolsSettings__PublishProducts`
* `CommercetoolsSettings__PublishProductVariants`

### Manual execution

To run the flow manually, use the following POST endpoint:

```
https://[root-url]/api/ManualDataTransfer
```

The request body is a JSON object with a `LastRunTime` parameter, which specifies the point in time the delta is calculated from. For a full synchronization, set it to a very early date.

```json theme={null}
{
  "LastRunTime": "2000-01-01T00:00:00.000Z"
}
```
