Flat-file exchange
The flat-file export plugin writes the placed orders to a CSV file, according to a documented contract, in an exchange directory that a business system can read. This page shows the contract and an excerpt of a file produced from the latest orders of the demonstration.
The contract of the file
A header line, then one line per order line.
- UTF-8 encoding, without a byte order mark.
- Semicolon separator; a field that contains a semicolon is enclosed in quotes.
- One line per order line, each ending with a line break.
- Amounts as integers in the minor unit of the currency, with no decimal point.
- One file per batch, with a unique name: orders, UTC date and time, then eight characters.
-
order_numberNumber of the order.
-
webhook_idId of the outbox event: the idempotence key on the reader side.
-
placed_atDate of the end of the checkout, in UTC.
-
currencyCurrency code of the order.
-
customer_emailAddress of the customer (masked in this excerpt).
-
variant_codeCode of the product variant.
-
quantityQuantity ordered.
-
unit_price_minorUnit price, in the minor unit.
-
line_total_minorTotal of the line, in the minor unit.
-
ship_countryCountry code of the shipping address.
An excerpt of a file
The first lines of the last file really produced by the plugin from the orders of the demonstration, for the channel shown (addresses masked).
order_number;webhook_id;placed_at;currency;customer_email;variant_code;quantity;unit_price_minor;line_total_minor;ship_country 000000015;01a239a1-958c-74ae-8efe-840c949082c8;2026-11-24T09:00:00Z;EUR;h***@globalmaint.example;EPI-GANT-001;20;1178;23560;FR 000000012;01a239a1-958c-7262-8efe-840c943a48a5;2026-11-26T09:00:00Z;EUR;a***@buildco.example;EPI-CHAU-001;60;6291;377460;FR 000000006;01a239a1-958b-7d27-a7f5-8010007383ec;2026-11-29T09:00:00Z;EUR;c***@acme.example;EPI-CASK-001;40;1588;63520;FR
Running it
A console command writes one batch; schedule it at the rhythm the reader reads the directory.
bin/console tmonier:erp-flatfile:export-orders
- The file is written under a provisional name then renamed: a reader never sees a partial file.
- Each event is exported once; delivery is at least once, the reader deduplicates on the event id.
- If the directory is missing, not writable or full, no file is left behind, the error is logged and the events stay to export.
- The plugin does not purge the directory: the retention of the files, which hold addresses, is set by the operator.