Inventories Exporter

This package helps in exporting inventories from the commercetools platform in csv and json format

Configuration

The constructor accepts four arguments:

  • apiConfig (Object): AuthMiddleware options for authentication on the commercetools platform. (Required. See here)

  • An optional logger object having four methods (info, warn, error and verbose)

  • exportConfig (Object): Internal Export configurations

    • delimiter (Object): CSV delimiter

    • format (Object): Export format 'csv', 'json'

    • channelKey (String): Channel key to use as filter for results to export. Useful if you have channel key but not id to build your queryString

    • queryString (String): Predicate to use to filter inventories to export

  • accessToken (String): Access token to be used to authenticate requests to API. Requires scope of [view_products]

Usage

npm install @commercetools/inventories-exporter --global

CLI

Usage: inventoriesexporter [options]
Export inventories from the commercetools platform.

Options:
  --help, -h        Show help text.                                    [boolean]
  --version         Show version number                                [boolean]
  --outputFile, -o  Path to output file.                     [default: "stdout"]
  --apiUrl          The host URL of the HTTP API service.
                                              [default: "https://api.europe-west1.gcp.commercetools.com"]
  --authUrl         The host URL of the OAuth API service.
                                             [default: "https://auth.europe-west1.gcp.commercetools.com"]
  --delimiter, -d   Used CSV delimiter.                           [default: ","]
  --accessToken     CTP client access token
  --projectKey, -p  API project key.                                  [required]
  --channelKey, -c  Channel key to use as filter for result to export.
                    Useful if you only have channel key but not id.
                    Can be used with the query flag

  --query, -q       Filter query for stocks:
                    https://docs.commercetools.com/http-api-projects-inventory.html#query-inventory
                    can be used with channelKey flag

  --template, -t    Path to a CSV template file with headers which should be
                    exported.
  --format, -f      Format for export [choices: "csv", "json"] [default: "json"]
  --logLevel        Logging level: error, warn, info or verbose.
                                                               [default: "info"]
  --logFile         Path to file where to save logs.
                                           [default: "inventories-exporter.log"]

JS

For direct usage

Last updated