> For the complete documentation index, see [llms.txt](https://docs.hubyte.de/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hubyte.de/dropshipping-bestellung-an-lieferanten-herstelle/english-documentation/csv-xml-export.md).

# CSV & XML export

The plugin can export order data as a **CSV** or **XML** file and send it as an email attachment to the supplier, or save it on the server.

The export configuration is done **per supplier** (under Catalogues > Dropshipping Suppliers > \[Supplier]).

***

## CSV export

### Basic settings

| Field                      | Description                                    | Example                         |
| -------------------------- | ---------------------------------------------- | ------------------------------- |
| **Send CSV as attachment** | Attaches the CSV to the email                  | ✓ active                        |
| **Delimiter**              | Field separator                                | `;` or `,` or `\|`              |
| **Filename**               | File name (Twig variables supported)           | `ORDER_{{ order.orderNumber }}` |
| **File path**              | Storage location on server (starting `files/`) | `files/dropshipping/`           |
| **Save file**              | Additionally saves CSV on the server           | optional                        |

### Defining the header

Enter the column names **line by line** — each line corresponds to one column:

```
OrderNumber
OrderDate
NetPrice
TotalPrice
Tax
ProductName
ManufacturerNumber
Quantity
```

### Defining columns

Enter one Twig template per line for the corresponding column. The order must match the header:

```twig
{{ order.orderNumber }}
{{ order.orderDate|date }}
{{ order.price.netPrice }}
{{ order.price.totalPrice }}
{{ order.price.calculatedTaxes.at(0).tax }}
{{ order.lineItems.at(n).label }}
{{ order.lineItems.at(n).payload.manufacturerNumber|default('') }}
{{ order.lineItems.at(n).quantity }}
```

> **Important:** `lineItems.at(n)` is a placeholder. The plugin automatically replaces `n` with the index of the current line item.

***

## XML export

### Basic settings

| Field             | Description                          |
| ----------------- | ------------------------------------ |
| **Export as XML** | Switches from CSV to XML format      |
| **File path**     | Storage location on server           |
| **Save file**     | Additionally saves XML on the server |

### XML structure

The XML file consists of three parts:

**Header** – output once at the beginning:

```xml
<?xml version="1.0" encoding="UTF-8"?><orders>
```

**Body** – repeated for **each order line item**:

```xml
<order>
  <number>{{ order.orderNumber }}</number>
  <date>{{ order.orderDate|date }}</date>
  <price>{{ order.price.netPrice }}</price>
  <total_price>{{ order.price.totalPrice }}</total_price>
  <tax>{{ order.price.calculatedTaxes.at(0).tax }}</tax>
  <item_name>{{ order.lineItems.at(n).label }}</item_name>
  <manufacturer_number>{{ order.lineItems.at(n).payload.manufacturerNumber|default('') }}</manufacturer_number>
  <quantity>{{ order.lineItems.at(n).quantity }}</quantity>
</order>
```

**Footer** – output once at the end:

```xml
</orders>
```

***

## Available Twig variables

### Order (`order`)

| Variable                                | Description                    | Example      |
| --------------------------------------- | ------------------------------ | ------------ |
| `order.orderNumber`                     | Order number                   | `10042`      |
| `order.orderDate`                       | Order date (timestamp)         | –            |
| `order.orderDate\|date`                 | Formatted date                 | `15.03.2024` |
| `order.orderDate\|date('d.m.Y')`        | Date with format specification | `15.03.2024` |
| `order.orderDate\|date('d-m-Y')`        | Date with hyphens              | `15-03-2024` |
| `order.price.netPrice`                  | Net total amount               | `84.03`      |
| `order.price.totalPrice`                | Gross total amount             | `100.00`     |
| `order.price.calculatedTaxes.at(0).tax` | Tax amount (first tax rate)    | `15.97`      |

### Order line items (`order.lineItems.at(n)`)

> `n` is automatically replaced by the current line item index.

| Variable                                           | Description                   | Example             |
| -------------------------------------------------- | ----------------------------- | ------------------- |
| `order.lineItems.at(n).label`                      | Product name                  | `"T-Shirt Blue XL"` |
| `order.lineItems.at(n).quantity`                   | Ordered quantity              | `2`                 |
| `order.lineItems.at(n).payload.manufacturerNumber` | Manufacturer / article number | `"MNR-001"`         |
| `order.lineItems.at(n).payload.productNumber`      | Shopware product number       | `"SW10042"`         |

### Supplier (`supplier`)

| Variable                  | Description                      |
| ------------------------- | -------------------------------- |
| `supplier.name`           | Supplier name                    |
| `supplier.mail`           | Primary email of the supplier    |
| `supplier.additionalMail` | Additional email of the supplier |

### Date formatting

Twig date formatting using PHP `date()` syntax:

| Format      | Description          | Example            |
| ----------- | -------------------- | ------------------ |
| `d.m.Y`     | Day.Month.Year       | `15.03.2024`       |
| `d-m-Y`     | Day-Month-Year       | `15-03-2024`       |
| `Y-m-d`     | Year-Month-Day (ISO) | `2024-03-15`       |
| `d/m/Y H:i` | With time            | `15/03/2024 14:30` |

***

## Practical examples

### Example 1: Simple CSV for an international supplier

**Header:**

```
OrderNumber
OrderDate
Product
ArticleNumber
Quantity
NetPrice
```

**Columns:**

```twig
{{ order.orderNumber }}
{{ order.orderDate|date('d.m.Y') }}
{{ order.lineItems.at(n).label }}
{{ order.lineItems.at(n).payload.manufacturerNumber|default('') }}
{{ order.lineItems.at(n).quantity }}
{{ order.price.netPrice }}
```

### Example 2: XML with multiple fields

```xml
Header:
<?xml version="1.0" encoding="UTF-8"?>
<orders>

Body:
<order>
  <ordernumber>{{ order.orderNumber }}</ordernumber>
  <date>{{ order.orderDate|date('d.m.Y') }}</date>
  <item>
    <name>{{ order.lineItems.at(n).label }}</name>
    <articlenumber>{{ order.lineItems.at(n).payload.manufacturerNumber|default('') }}</articlenumber>
    <quantity>{{ order.lineItems.at(n).quantity }}</quantity>
  </item>
  <prices>
    <net>{{ order.price.netPrice }}</net>
    <gross>{{ order.price.totalPrice }}</gross>
  </prices>
</order>

Footer:
</orders>
```

### Example 3: Filename with date and order number

```twig
ORDER_{{ order.orderNumber }}_{{ order.orderDate|date('Y-m-d') }}
```

Result: `ORDER_10042_2024-03-15.csv`

***

## Tips & notes

* **Twig filters:** You can use all standard Twig filters, e.g. `|upper`, `|lower`, `|default('')`
* **Missing values:** Use `|default('')` to avoid errors on empty fields: `{{ order.lineItems.at(n).payload.manufacturerNumber|default('') }}`
* **Encoding:** XML files are encoded in UTF-8
* **Delimiter:** For numeric values with a decimal comma, a semicolon may work better as the delimiter than a comma


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hubyte.de/dropshipping-bestellung-an-lieferanten-herstelle/english-documentation/csv-xml-export.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
