GithubHelp home page GithubHelp logo

damarna85 / sphere-order-export Goto Github PK

View Code? Open in Web Editor NEW

This project forked from commercetools/sphere-order-export

0.0 1.0 0.0 502 KB

Quick and easy way to export your orders from SPHERE.IO into files, with SFTP support!

Home Page: https://impex.sphere.io

License: MIT License

JavaScript 0.43% CoffeeScript 97.64% Shell 1.36% HTML 0.57%

sphere-order-export's Introduction

commercetools logo

Order export

NPM

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

SFTP

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"?>
<order>
  <xsdVersion>0.9</xsdVersion>
  <id>a095493f-0750-41fe-9fa7-77cad095fe2a</id>
  <version>1</version>
  <createdAt>2014-10-13T09:20:04.961Z</createdAt>
  <lastModifiedAt>2014-10-13T09:20:04.961Z</lastModifiedAt>
  ...
</order>

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).

id,orderNumber,totalPrice,totalNet,totalGross

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:

id,orderNumber,price,lineItems.id,lineItems.productId,billingAddress.firstName
123,10001,USD 5950,,,John
123,10001,,LineItemId-1-1,ProductId-1-1,
123,10001,,LineItemId-1-2,ProductId-1-2,

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

id,orderNumber,price,lineItems.id,lineItems.productId,billingAddress.firstName
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:

id,orderNumber,custom.fields.stringField,custom.fields.booleanField
1,10001,abcd,1
2,10002,efgh,

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

Example template for exporting lineItem attributes:

id,orderNumber,lineItems.variant.attributes.color,lineItems.variant.attributes.size_code,lineItems.variant.attributes.product_length,lineItems.variant.attributes.ean_codes,lineItems.variant.attributes.filter_colors,lineItems.variant.attributes.pinned,lineItems.variant.attributes.delivery_time

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:

orderNumber,delivery.id,_itemGroupId,item.id,item.quantity,parcel.id,parcel.length,parcel.height,parcel.width,parcel.weight,parcel.trackingId,parcel.carrier,parcel.provider,parcel.providerTransaction,parcel.isReturn

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

Contributing

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

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

License

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

sphere-order-export's People

Contributors

babanila avatar celeste-horgan avatar daern91 avatar emmenko avatar hajoeichler avatar hisabimbola avatar junajan avatar mmoelli avatar philippspo avatar renovate-bot avatar renovate[bot] avatar svenmueller avatar valesauer avatar vasumathijayakumar avatar wizzy25 avatar yanns avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.