> For the complete documentation index, see [llms.txt](https://developer.emporix.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.emporix.io/import-tool/import-configuration-examples/importing-product-variants.md).

# Importing Products with Variants

Import a multi-level catalog with variants, such as style, color, and size, so that each sellable SKU is created under its parent with its own price and stock.

A catalog with variants, such as T-shirts in several colors and sizes, has parent products and sellable variants. This example imports a three-level dynamic variant tree from CSV files: **styles** (parents), **colours** (middle level), and **sizes** (sellable SKUs), plus a **categories** file that the styles are assigned to. Without variant settings, the same files would arrive as unrelated basic products.

To learn what parent products and variants are in Emporix, see [Parent products and product variants](https://developer.emporix.io/user-guides/core-commerce/product.md#parent-products-and-product-variants).

{% hint style="info" %}
The CSV files are only an example source. A Celonis or HTTP / REST API source works the same way. Only the connection and source setup differ.
{% endhint %}

## How this catalog maps to streams

The sample uses **four streams in one import**, each with its own file:

| Stream     | File                         | Role                                                                                                     |
| ---------- | ---------------------------- | -------------------------------------------------------------------------------------------------------- |
| Categories | `it_variants_categories.csv` | Creates the category tree (`Apparel` → `T-shirts` / `Hoodies`)                                           |
| Styles     | `it_variants_styles.csv`     | Parent products (**Product type** = parents). One row per style, for example Classic T-shirt             |
| Colours    | `it_variants_colours.csv`    | Variants of styles (**Product type** = variants). One row per colour. Not sellable on its own            |
| Sizes      | `it_variants_sizes.csv`      | Variants of colours (**Product type** = variants). One row per size SKU. Sellable; holds price and stock |

Set run order so each level runs after the level above it: Styles **Depends on** Categories. For variant streams, set **Parent feed** to the stream above (Colours → Styles, Sizes → Colours); that also adds the parent stream to **Depends on**.

A stream that imports products without variants keeps the default **Product type**, **BASIC**.

All three product streams must use the same **Variant model**. This walkthrough uses **Dynamic variants** (any attribute value, no product template). For template variants, see [Use template variants](#use-template-variants).

The **Product type** options name the Emporix product type that the chosen model creates. With dynamic variants, parents and variants are both `DYNAMIC_VARIANT` products. With template variants, parents are `PARENT_VARIANT` products and variants are `VARIANT` products.

Dynamic variants can nest up to four levels. A middle level is a variant of the level above it and the parent of the level below it.

## Before you start

Before you start:

* Check that your user can create products and categories. Access is set on your user group in Management Dashboard — see [Users and Groups](https://developer.emporix.io/user-guides/management-dashboard/administration/usersandgroups.md).
* If you use template variants instead of this dynamic example, prepare a [product template](https://developer.emporix.io/user-guides/management-dashboard/products-module/product-templates.md) whose variant attributes match the source columns, for example `color` and `size`. See [Creating a new template](https://developer.emporix.io/user-guides/management-dashboard/products-module/product-templates.md#creating-a-new-template).
* For price and stock fan-out on the sizes stream, know a site code other than `main`, a country code, a currency, and a price model ID from your tenant (the same values you use for prices in Management Dashboard).

## Download the sample files

The sample has three categories, two styles, four colours, and twelve size SKUs.

{% file src="/files/TcUS6a5GtZ1mbvGK83Og" %}

{% file src="/files/mivZftaOpLJQKzqjdfeL" %}

{% file src="/files/2mUnhWYw2SjRBL0n0TWl" %}

{% file src="/files/W3ZgP9ECfP98IKQKCxCg" %}

How the files link:

* **Categories** – `code`, `name`, and optional `parentCode` for a child category under another category.
* **Styles** – one row per parent product (`code`). `categories` holds the category code, for example `MDEMO-TSHIRTS`.
* **Colours** – one row per colour variant (`code`). `style` holds the parent style code. `color` is the variant attribute.
* **Sizes** – one row per sellable SKU (`sku`). `colour` holds the parent colour code. `size` is the variant attribute. `price-EUR` and `stock` feed the fan-out targets.

The files also carry extra columns such as `fabric`, `careInstructions`, `colourFamily`, `hexCode`, `fit`, and `ean`. This walkthrough maps only what you need for the hierarchy, names, categories, prices, and stock. You can map the rest to product fields or mixins later.

{% hint style="warning" %}
These sample files use a **semicolon ( ; )** as the column separator, not a comma. The File connection defaults to comma. Change **Column separator** to **Semicolon ( ; )** and save **before** you upload each sample. If you leave the default, **Key field** shows the whole header as one value (for example `code;name;parentCode`) and you cannot select `code` alone.
{% endhint %}

## Import the catalog with dynamic variants

{% stepper %}
{% step %}

#### Create a connection for each file

A File connection holds one sample file, and its columns become the fields you map. Create four File connections as described in [Importing Using CSV](https://developer.emporix.io/import-tool/import-configuration-examples/csv-example.md), one per sample file. For each connection, use:

* **Source type** – **File**
* **File format** – **CSV (delimited text)**
* **Column separator** – **Semicolon ( ; )** — required for these samples; change this from the default comma **before** you upload
* **Character encoding** – **UTF-8**

Save the connection, then upload the matching sample file. After a correct upload, **Key field** lists separate columns such as `code` or `sku`. If you see one long `code;name;...` value, the separator is still comma — fix it and re-upload the sample.
{% endstep %}

{% step %}

#### Create the categories stream

In the import, create a stream with the following settings:

* **Name** – `Categories`
* **Connection** – the connection with the categories file
* **Source record** – `it_variants_categories.csv`
* **Key field** – `code`
* **Target** – **Category**

Map:

| Source field | Target field |
| ------------ | ------------ |
| `code`       | `code`       |
| `name`       | `name`       |
| `parentCode` | `parentCode` |

Choose **Save**, then **Publish**. Child categories (`MDEMO-TSHIRTS`, `MDEMO-HOODIES`) link to `MDEMO-APPAREL` through `parentCode`.

<figure><img src="https://2637457592-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9VS91qn3Ylwd58YivX1A%2Fuploads%2Fgit-blob-9f48163f89641962d851a7bd388a5401b6bfad89%2Fit_variants_categories_mapping.png?alt=media" alt="Field mapping of the categories stream with code, name, and parentCode"><figcaption><p>Categories stream field mapping</p></figcaption></figure>
{% endstep %}

{% step %}

#### Create the styles stream (parents)

Create a Product stream with the following settings:

* **Name** – `Styles`
* **Connection** – the connection with the styles file
* **Source record** – `it_variants_styles.csv`
* **Key field** – `code`
* **Target** – **Product**, with **Find products by** set to **Product code (SKU)**
* **Find categories by** – category code (so the `categories` column can match the codes from the categories stream)
* **Product type** – the parents option, **DYNAMIC\_VARIANT — parents, their variants come from another stream**
* **Variant model** – **Dynamic variants**
* **Depends on** – `Categories`

Map:

| Source field        | Target field  |
| ------------------- | ------------- |
| `code`              | `code`        |
| `name-en_US`        | `name`        |
| `description-en_US` | `description` |
| `categories`        | `categories`  |

To keep test products unpublished, add a row with an empty source field, the target field `published`, and the transform `constant:false`. See [Field Mapping](https://developer.emporix.io/import-tool/import-setup-and-jobs/imports/field-mapping.md).

A dynamic parent is created as not sellable, because customers buy its variants. Leave `sellable` unmapped. Choose **Save**, then **Publish**.

<figure><img src="https://2637457592-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9VS91qn3Ylwd58YivX1A%2Fuploads%2Fgit-blob-1d8ee2fc8f6d7ac5f7703cc42ebb4333246ee546%2Fit_variants_style_mapping.png?alt=media" alt="Field mapping of the styles stream with code, categories, name, and description"><figcaption><p>Styles stream field mapping</p></figcaption></figure>
{% endstep %}

{% step %}

#### Create the colours stream (middle level)

Create a second Product stream:

* **Name** – `Colours`
* **Connection** – the connection with the colours file
* **Source record** – `it_variants_colours.csv`
* **Key field** – `code`
* **Target** – **Product**, with **Find products by** set to **Product code (SKU)**
* **Product type** – the variants option, **DYNAMIC\_VARIANT — variants of parents**
* **Variant model** – **Dynamic variants**
* **Parent feed** – `Styles`

Map:

| Source field | Target field              |
| ------------ | ------------------------- |
| `code`       | `code`                    |
| `style`      | `parentCode`              |
| `color`      | `variantAttributes.color` |
| `name-en_US` | `name`                    |

`parentCode` links each colour to its style. **Parent feed** is also added to **Depends on**, so Styles runs before Colours. A colour is not bought on its own, so add a row with an empty source field, the target field `sellable`, and the transform `constant:false`. Add the `published` row as for styles if you want colours unpublished. Choose **Save**, then **Publish**.

<figure><img src="https://2637457592-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9VS91qn3Ylwd58YivX1A%2Fuploads%2Fgit-blob-ed5b1943e305cd1b4301eb088fb1008aa50a9d50%2Fit_variants_color_mapping.png?alt=media" alt="Field mapping of the colours stream with parentCode and variantAttributes.color"><figcaption><p>Colours stream field mapping</p></figcaption></figure>
{% endstep %}

{% step %}

#### Create the sizes stream (sellable variants)

Create a third Product stream:

* **Name** – `Sizes`
* **Connection** – the connection with the sizes file
* **Source record** – `it_variants_sizes.csv`
* **Key field** – `sku`
* **Target** – **Product**, with **Find products by** set to **Product code (SKU)**
* **Product type** – the variants option, **DYNAMIC\_VARIANT — variants of parents**
* **Variant model** – **Dynamic variants**
* **Parent feed** – `Colours`

Map:

| Source field | Target field             |
| ------------ | ------------------------ |
| `sku`        | `code`                   |
| `colour`     | `parentCode`             |
| `size`       | `variantAttributes.size` |
| `name-en_US` | `name`                   |

The sizes file uses `sku` as the column name, but the Product target has no `sku` field. Map that column to `code`. If you used **Map from source**, it may add a row that targets `sku` — change that target to `code`, or delete the row and add `sku` → `code` yourself. A leftover `sku` target fails with a message that `sku` is not a product field and names no mixin.

A size does not repeat its colour attribute; it inherits colour from its parent. **Parent feed** is also added to **Depends on**, so Colours runs before Sizes. Sizes are sellable by default — leave `sellable` unmapped, or set `constant:true` if you prefer to be explicit. Add the `published` row if you want them unpublished. Choose **Save**, then **Publish**.

<figure><img src="https://2637457592-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9VS91qn3Ylwd58YivX1A%2Fuploads%2Fgit-blob-c20340dad884d30b14d85bb004714c0a679ec4ca%2Fit_variants_size_mapping.png?alt=media" alt="Field mapping of the sizes stream with sku mapped to code, parentCode, and variantAttributes.size"><figcaption><p>Sizes stream field mapping with sku mapped to code</p></figcaption></figure>
{% endstep %}

{% step %}

#### (Optional) Add price and stock fan-out on sizes

Skip this step if you only want to import the variant hierarchy. Categories, Styles, Colours, and Sizes are enough to create the products. Add price and stock later when you want commercial data on the sellable SKUs.

A size is the product that customers buy, so its price and stock belong on the **Sizes** stream. Add them as [fan-out targets](https://developer.emporix.io/import-tool/import-setup-and-jobs/imports/field-mapping.md#add-fan-out-targets) of that stream (not of Styles or Colours).

**Price** — this is all in the **mapping**, not in separate Price target settings. The Price tab mainly has **Write this target**. Values that are missing from the CSV (currency, site, country, price model) are mapping rows with an empty source field and a `constant:<value>` transform. See [Field Mapping](https://developer.emporix.io/import-tool/import-setup-and-jobs/imports/field-mapping.md) for `constant:<value>`.

1. Choose **+ Add target** (or **Add fan-out target**), name it for example `Prices`, and set **Target** to **Price**.
2. Turn on **Write this target**.
3. Choose **Map from source** or **+ Add row**, then map as follows. Pick the target field names the Price mapper offers (labels can vary slightly).

| Source field | Target field (typical)    | Transform                                         |
| ------------ | ------------------------- | ------------------------------------------------- |
| `price-EUR`  | Price amount / tier value | –                                                 |
| *(empty)*    | Currency                  | `constant:EUR`                                    |
| *(empty)*    | Site / site code          | `constant:<your-site-code>` — not `main`          |
| *(empty)*    | Country                   | `constant:<your-country-code>` — for example `DE` |
| *(empty)*    | Price model               | `constant:<your-price-model-id>`                  |

Use the same site, country, currency, and price model ID you already use for other prices in Management Dashboard.

**Availability (stock)** — unlike Price, stock has a **site** control on the target settings.

1. Add another fan-out target with **Target** set to **Availability (stock)**.
2. Turn on **Write this target** and select the site that holds the stock. Do not use the `main` site.
3. Map `stock` to the stock level.

Optionally add **Product media (image links)** on Styles or Colours for the `image` column.

For a fan-out walkthrough with stock, see [Importing Products from CSV](https://developer.emporix.io/import-tool/import-configuration-examples/importing-to-multiple-entities.md).
{% endstep %}

{% step %}

#### Queue the files

On each stream's **Files** tab, upload its file so that it appears under **Waiting to import**. Confirm **File format** still uses **Semicolon ( ; )**. Then continue with [Test the import](#test-the-import).
{% endstep %}
{% endstepper %}

## Test the import

{% stepper %}
{% step %}

#### Dry run the import

Run a dry run of the import. A dry run maps the rows without writing products, so variants are previewed even though their parents do not exist yet. Confirm that each colour and size row has its `parentCode` and attribute values. See [Running and Monitoring Imports](https://developer.emporix.io/import-tool/import-setup-and-jobs/imports/running-imports.md).
{% endstep %}

{% step %}

#### Run and check the result

Run the import. In Management Dashboard, open [Products](https://developer.emporix.io/user-guides/management-dashboard/products-module/products.md) and check that each style lists its colours, and each colour lists its sizes. Check that the styles appear under the demo categories. If you added the optional price and stock targets, also confirm those on the size SKUs.

<figure><img src="https://2637457592-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9VS91qn3Ylwd58YivX1A%2Fuploads%2Fgit-blob-f6ba6390ac9a8278b3b737cdef5a6e31a72be614%2Fit_variants_MD_check.png?alt=media" alt="Management Dashboard product hierarchy for Zip hoodie with colour and size variants"><figcaption><p>Imported variant hierarchy in Management Dashboard</p></figcaption></figure>
{% endstep %}

{% step %}

#### Test an update

Change a size's name in the sizes file, upload it again, and run the import. The existing size is updated under the same colour, and no new product is created.
{% endstep %}
{% endstepper %}

## Rules to know

The following rules apply when you import parents and variants:

* A product's type and its parent are set when the product is created and never change. A row that would turn a basic product into a parent, or move a variant to another parent, fails with a message. To import such a product differently, delete it in Management Dashboard, then run the import again.
* The stream's **Product type** decides the type of the products it creates. A mapped `productType` is not used for parents and variants.
* A variant's parent must exist when the variant is written. Parents imported by another import, or created by hand, are found by their code. Leave **Parent feed** empty when parents come from elsewhere.
* Rows that share a key are merged into one product. Use [Check key](https://developer.emporix.io/import-tool/import-setup-and-jobs/imports/configuring-streams.md#check-key) to test the key of each stream before the first run.

## Use template variants

For template variants, set **Variant model** to **Template variants** on the parent and variant streams and select the same **Product template** on both. The **Product type** options then name `PARENT_VARIANT` for parents and `VARIANT` for variants.

After you select the template, the variant attributes it declares are listed under **Variant model**. Check that they match the columns you map, for example `color` and `size`. The mapping editor offers each one as a target, and you map it in the same way as a dynamic variant, for example `color` to `variantAttributes.color`.

The Import Tool adds to each parent only the attribute values that its variants use. A variant whose value the template does not allow fails, and the Import Tool does not change the template. Add the value to the [product template](https://developer.emporix.io/user-guides/management-dashboard/products-module/product-templates.md) in Management Dashboard, then run the import again.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developer.emporix.io/import-tool/import-configuration-examples/importing-product-variants.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
