---
updatedAt: 2025-09-25T18:13:45.000Z
agentTools:
  projectIndex: https://docs.constructor.com/llms.txt
---

# Commercetools helper functions

You can use the helper functions listed below when developing templates for use with our [commercetools connector](https://docs.constructor.com/docs/integrating-with-constructor-platform-connectors-catalog-connectors-commercetools-connector).

Please note that some functions are only compatible with certain template types.

# `$getCategoryId`

Returns a sanitized ID from the current category.

**Template compatibility:** `item group`

## Input

None

## Examples

```json item_group.jsonata
$getCategoryId()
=> '42'
```

# `$getProductId`

Returns a sanitized ID from the current product.

**Template compatibility:** `item`

## Input

None

## Examples

```json item.jsonata
$getProductId()
=> '42'
```

# `$getVariantId`

Returns a sanitized ID from the current variant.

**Template compatibility:** `variation`.

## Input

None

## Examples

```json variation.jsonata
$getVariantId()
=> '42'
```

# `$getImageUrl`

Returns the main image URL of the current product or variant.

Template compatibility: `item`, `variation`.

## Input

None

## Examples

```json item.jsonata
$getImageUrl()
=> 'https://example.com/image.jpg'
```

# `$getProductUrl`

Returns the main URL of the current product.

**Template compatibility:** `item`, `variation`.

## Input

None

## Examples

```json item.jsonata
$getProductUrl()
=> 'https://example.com/product-slug'
```

# `$getItemKeywords`

Returns the keywords of the current product.

**Template compatibility:** `item`

## Input

None

## Examples

```json item.jsonata
$getItemKeywords()
=> ['clothing', 't-shirts']
```

# `$getAttributeValue`

Extracts the value from a custom attribute of the current product. Takes the attribute name as the first argument, and a locale as an optional second argument.

The attribute value will be parsed and extracted according to its type in commercetools:

* **Money:** will return the value of the `centAmount` field.
* **Enum:** will return the value of the `key` field.
* **Reference:** will return the value of the `id` field.
* **Set:** will return an array of the values on each `key` field.
* **Localized text:** will return the value under the specified locale.
* Otherwise, it will return the raw value for all other types.

**Template compatibility:** `item`, `variation`.

## Input

An attribute name, a locale (optional)

## Examples

```json item.jsonata
$getAttributeValue('price')
=> 4200

$getAttributeValue('color', 'fr-FR')
=> 'bleue'
```