> 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-to-multiple-entities.md).

# Importing Products from CSV

Import products, category assignments, and product availability from one CSV file using multiple targets.

This example uses one CSV row for each product. The main target creates the basic product, while two fan-out targets assign its category and set its stock for a site. The Import Tool reads each row once and writes to all three targets.

{% hint style="info" %}
The CSV file is only an example source. You can import products in the same way from any connection type: Celonis, HTTP / REST API, or File. Only the connection and source setup differ; the product target, fan-out targets, and field mapping work the same way.
{% endhint %}

## Before you start

Prepare the following before you start:

* An existing category and its **ID** – category assignment uses the category ID, not its code
* An existing site and its **code** – product availability uses the site code, not the site ID; do not use the `main` site
* Permission to create products, assign categories, and set product availability

The product IDs in the sample are supplied explicitly so the main target and fan-out targets can refer to the same products.

## Download and prepare the sample

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

```csv
productId,productCode,productNameEn,productType,published,categoryId,siteCode,stockLevel,distributionChannel
fanoutchair001,FANOUT-CHAIR-001,Fan-out Oak Chair,BASIC,false,REPLACE_WITH_CATEGORY_ID,REPLACE_WITH_SITE_CODE,25,ASSORTMENT
fanoutlamp001,FANOUT-LAMP-001,Fan-out Desk Lamp,BASIC,false,REPLACE_WITH_CATEGORY_ID,REPLACE_WITH_SITE_CODE,12,ASSORTMENT
```

Before you upload the file, do the following:

1. Replace `REPLACE_WITH_CATEGORY_ID` with the ID of an existing category.
2. Replace `REPLACE_WITH_SITE_CODE` with the code of an existing site.
3. Keep `published` set to `false` so the test products are not published.

Each row contains fields for all three targets:

| Target               | Source columns                                                          |
| -------------------- | ----------------------------------------------------------------------- |
| Basic product        | `productId`, `productCode`, `productNameEn`, `productType`, `published` |
| Category assignment  | `productId`, `categoryId`                                               |
| Product availability | `productId`, `siteCode`, `stockLevel`, `distributionChannel`            |

## Create the File stream

{% stepper %}
{% step %}

#### Create the connection and stream

Follow [Importing Using CSV](https://developer.emporix.io/import-tool/import-configuration-examples/csv-example.md) to create a **File** connection and upload the prepared CSV as its sample file. Create a stream with:

* **Name** – `Product fan-out`
* **Source record** – `product-fan-out-sample.csv`
* **Key field** – `productId`
* **Target** – **Product**
  {% endstep %}

{% step %}

#### Queue the CSV for import

The sample file on the connection is only for discovery. Before you run the import, open the stream **Files** tab and upload the prepared CSV so it appears under **Waiting to import**. See [Files](https://developer.emporix.io/import-tool/import-setup-and-jobs/imports/configuring-streams.md#files).
{% endstep %}

{% step %}

#### Map and publish the product target

Open **Edit mapping** and map the main product target:

| Source field    | Product field  |
| --------------- | -------------- |
| `productId`     | ID             |
| `productCode`   | Code           |
| `productNameEn` | Name – English |
| `productType`   | Product type   |
| `published`     | Published      |

Field labels can vary with the selected target schema. Choose **Map from source**, then adjust any rows that did not match. You must map fields before you can save. Use **Preview** to confirm that the mapped product contains an ID, code, and English name. Choose **Save**, then **Publish** for the product target.
{% endstep %}
{% endstepper %}

## Add the fan-out targets

{% stepper %}
{% step %}

#### Add the category assignment target

Choose **+ Add target** and set:

* **Name** – `Category assignments`
* **Target** – **Category assignment**
* **Write one per item of** – **One per feed row**

On the new target tab, turn on **Write this target** and choose **Id** under **Find categories by**. Choose **Map from source**, then map the category ID. Without a mapping for the category ID, you cannot save the target.

| Source field | Category assignment field |
| ------------ | ------------------------- |
| `productId`  | Product ID                |
| `categoryId` | Category ID               |

<figure><img src="https://2637457592-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9VS91qn3Ylwd58YivX1A%2Fuploads%2Fgit-blob-431a5ac4bb0bbdc4fb0f06fb76ef0c97119056a2%2Fit_fan_out_category.png?alt=media" alt="Category assignments target tab with Write this target on and Find categories by Id"><figcaption><p>Category assignment target with Write this target enabled</p></figcaption></figure>

Confirm in the preview that the assignment references `productId` and the expected category ID. Choose **Save** and **Publish** on this target tab. Each target is published separately.

After a successful run, open **Management Dashboard** and check the category. The imported products appear there and are assigned to that category.
{% endstep %}

{% step %}

#### Add the product availability target

Choose **+ Add target** again and set:

* **Name** – `Availability`
* **Target** – **Availability (stock)**
* **Write one per item of** – **One per feed row**

Turn on **Write this target** and select the site for the stock. Choose **Map from source**, then map `siteCode` to that site. Without a mapping from `siteCode` to the site, you cannot save the target.

| Source field          | Availability field   |
| --------------------- | -------------------- |
| `productId`           | Product ID           |
| `siteCode`            | Site                 |
| `stockLevel`          | Stock level          |
| `distributionChannel` | Distribution channel |

Confirm the mapping in the preview, then choose **Save** and **Publish** on this target tab.

For details about the controls, see [Add fan-out targets](https://developer.emporix.io/import-tool/import-setup-and-jobs/imports/field-mapping.md#add-fan-out-targets).

{% hint style="info" %}
To import only category assignment or only product availability, turn off **Write this target** on the fan-out target you do not need.
{% endhint %}
{% endstep %}
{% endstepper %}

## Test the import

{% stepper %}
{% step %}

#### Dry run the draft mappings

Confirm that each source row produces a basic product, one category assignment, and product availability for the selected site, with matching product IDs. See [Running and Monitoring Imports](https://developer.emporix.io/import-tool/import-setup-and-jobs/imports/running-imports.md).
{% endstep %}

{% step %}

#### Publish every target and dry run again

Publish every target, then dry run again with the published mappings and confirm the output has not changed.
{% endstep %}

{% step %}

#### Queue and run the two-row file

If the CSV is not already under **Waiting to import**, upload it on the stream **Files** tab, then run a full import.
{% endstep %}

{% step %}

#### Verify all targets

Check that:

* products `fanoutchair001` and `fanoutlamp001` exist with the expected codes and English names
* in **Management Dashboard**, the selected category lists both imported products and they are assigned to that category
* on each product **Availability** tab, the selected site shows stock levels `25` and `12`

<figure><img src="https://2637457592-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9VS91qn3Ylwd58YivX1A%2Fuploads%2Fgit-blob-69be097f0bff8039c775ff438238f8adc397b133%2Fit_fan_out_productMD.png?alt=media" alt="Management Dashboard product details for Fan-out Oak Chair after import"><figcaption><p>Imported product in Management Dashboard after a successful run</p></figcaption></figure>
{% endstep %}

{% step %}

#### Test an update

Change the chair name and its `stockLevel` from `25` to `30`, save the CSV, and upload it again. The Import Tool does not accept identical file content twice. Run the import and confirm that the existing product and its site stock are updated without duplicate products or category assignments.
{% endstep %}

{% step %}

#### Test validation separately

In a copy of the file, use an invalid category ID for one row. Start with a dry run, then use a disposable tenant if you need to test the real failure. Review the run history and each target outcome to see whether the valid targets were written and how the failed target is reported.
{% endstep %}
{% endstepper %}

After the test, remove the sample products and their category assignments if you no longer need them. Site stock on those products is removed when you delete the products.

When the catalog has variants, such as sizes and colors, see [Importing Products with Variants](https://developer.emporix.io/import-tool/import-configuration-examples/importing-product-variants.md).


---

# 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-to-multiple-entities.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.
