Miss any of our Open RFC calls?Watch the recordings here! »


3.1.0 • Public • Published

commercetools logo

Order export


Build Status NPM version Coverage Status Dependency Status devDependency Status

This module allows to export orders to XML or CSV, with SFTP support and order deliveries to CSV file.

By default XML export will result in each file pro order

Getting started

$ npm install -g sphere-order-export
# output help screen for order export 
$ order-export
# output help screen for delivery export 
$ delivery-export


Exported orders (XML or CSV) can be automatically uploaded to an SFTP server.

When using SFTP you need to provide at least the required --sftp* options:

  • --sftpCredentials (or --sftpHost, --sftpUsername, --sftpPassword)
  • --sftpSource
  • --sftpTarget

Note that only exported SFTP orders are marked as synced (syncInfo) with the channel key OrderXmlFileExport

XML Format (default)

Orders exported in XML will result in each file pro order like

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

CSV Format

Orders exported in CSV are stored in a single file

At the moment you need to provide a --csvTemplate with headers in order to export related fields (see examples).


The following headers can be used in the CSV template

  • id
  • orderNumber
  • totalPrice -> results in a formated output of the price like USD 9999
  • totalPrice.centAmount -> results in the pure number of 9999 (allows better sorting)
  • totalNet
  • totalGross
  • customerGroup
  • customLineItems.* - eg. id, state, quantity or slug
  • lineItems.* - eg. id, state, quantity or supplyChannel
  • lineItems.variant.* - eg. sku, variantId, availability, prices or images
  • lineItems.variant.attributes.* - eg. lineItems.variant.attributes.color will export attribute with name color
  • custom.fields.* - eg. custom.fields.fieldName will export custom field
  • shippingAddress.* - eg. lastName or postalCode
  • billingAddress.*
  • custom.fields.* - eg. custom.fields.fieldName will export custom field
  • paymentInfo - will export all associated payment IDs

In general you can get access to any property of the order object. Find a reference in our API documentation.

Note that when at least one lineItems header is given the resulting CSV contains a row per lineItem. Otherwise it only contains one row per order.

When exporting order with its line items, all redundant info (eg. general order information) is removed and printed only once in the first rows:

123,10001,USD 5950,,,John

If needed you can specify a --fillAllRows parameter which will put general info also to line items rows:

123,10001,USD 5950,,,John
123,10001,USD 5950,LineItemId-1-1,ProductId-1-1,John
123,10001,USD 5950,LineItemId-1-2,ProductId-1-2,John

Example with custom fields:


Booleans with a false value are mapped as an empty string and true value is mapped as 1.

Example template for exporting lineItem attributes:


Delivery export

It is possible to export order deliveries into CSV with the following command.

$ delivery-export --projectKey <project-key> --targetDir exportedDeliveries

This will create an exportedDeliveries folder with a deliveries.csv file where all deliveries are stored.

Exported CSV file has these fields:


And the structure is more described in the csv-parser-order package here.


In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt. More info here.


Releasing a new version is completely automated using the Grunt task grunt release.

grunt release // patch release
grunt release:minor // minor release
grunt release:major // major release


Copyright (c) 2014 SPHERE.IO Licensed under the MIT license.


npm i sphere-order-export

DownloadsWeekly Downloads






Unpacked Size

299 kB

Total Files


Last publish


  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar