Export order data

We can use the WebSphere Commerce REST API to export order data of a specific store. The output is exported in CSV format.


Before beginning

Ensure that the Swagger UI and the REST Discovery API are enabled. See
Enable and disabling the REST Discovery API.

Note: By default, for each store, only 1 order export is allowed per user (with the appropriate access control role) per hour. To change the minimum time between exports, see Configure the minimum elapsed time between order exports.


Procedure

  1. Use the Organization Administration Console to assign the following roles to a WebSphere Commerce user:

    • Assign the Registered Customer role to the user. This role allows users to log in to the store and access the order export tools in the Swagger UI. This role is necessary if the user password is expired and must be reset using the storefront.

    • Assign any of the following roles to provide access to export and download order data:

      • Operations Manager

      • Buyer ( sell side)

      • Category Manager

      • Marketing Manager

      • Operations Manager

      • Logistics Manager

      • Sales Manager

      • Product Manager

      • Seller

      • Site Administrator

  2. Go to the Aurora starter store and log in to the store with a user account that has access to export orders. We need to log in to use the order export REST services that are in the Swagger UI.

  3. Open a web browser and go to the following URL to access the Swagger UI: https://hostname/webapp/wcs/stores/servlet/swagger/index.html

    In the Swagger UI, the order_export class is used to export order data. Then, the order_download class is used to download the exported order data.

  4. Export the order data.

    1. Expand the order_export class.

    2. Expand the POST /store/{storeId}/order_export/ method path.

    3. Enter the necessary parameters.

      Parameter Value
      storeId

      Note: storeId is a mandatory parameter.

      The store identifier.
      body

      Note: Specify optional parameters in JSON format.

      There are two values that we can submit.

        status
        Only export orders with the specified status. Valid values are based on the STATUS column of the
        ORDERS database table.If status is not specified, then the following default values are used

          "A","B","C","D","F","G","H","I","M","R","S","W"

        Note: The default list assumes that Sterling Order Management is used. Therefore, if the environment is not integrated with Sterling Order Management, then we might notice that the list contains more STATUS values than your ORDERS table.

        timePlacedInDays
        Export orders that were placed x days since the current time. For example, 0 represents all orders that were placed since 12:00am today. 1 represents all orders since 12:00am yesterday.

        If timePlacedInDays is not specified, then 0 is used by default.

      For example, the following parameters exports orders that were placed within the last 100 days and have a status of 'M', 'A', or 'B'.

        {
           "status":"M,A,B",
           "timePlacedInDays":"100"
        }

    4. Click Try it out!

      Note: The order export is stored in the UPLOADFILE database table.

    5. Note the exportId in the response body. The exportId is used to download the order data in the proceeding step.

  5. Download the exported order data.

    1. Expand the order_download class.

    2. Expand the GET /store/{storeId}/order_download/byExportId/ method path.

    3. Enter the storeId that you previously used, and the exportId from step 4.e.

    4. Click Try it out!

    5. The response body contains the exported order data in CSV format.

    6. Download the CSV file by going to the response request URL in your web browser. For example, for a store with storeId 10151 and exportId 10001, the request response URL is

        https://localhost:443/wcs/resources/store/10151/order_download/byExportId/10001