tl;dr There are import APIs for both catalogs and inventory sets, but they are designed around importing data that was exported from another Commerce Engine installation. Custom imports could be massaged to match the expected format, but it's probably not worth it.
Importing Catalogs
The ImportCatalog()
OData API might do what you need, but the archive file it accepts has very specific contents.
If want to create items from a custom CSV or other source, you're better off creating your own Commerce plugin that exposes a Controller / Command.
Read on for a breakdown of the ImportCatalog()
API.
ImportCatalog()
accepts:
- A zip file via the
importFile
parameter, the structure of which is defined below
- A
mode
string parameter - if that parameter is "replace", all catalog data will be deleted before the import starts. If mode is anything else, entities will be replaced by their ID.
The expected structure of the file is JSON files of serialized Commerce entities, complete with $type
attribution and embedded components.
For most entities, the expected filename is EntityName.*.json
(eg. SellableItem.1.json
). Entities of this format that will be imported are:
RelationshipDefinition.*.json
LocalizationEntity.*.json
Catalog.*.json
Category.*.json
SellableItem.*.json
In that order.
Relationships are imported from any zip entries in the Relationships/
folder. Each file is expected to be a serialized List<RelationshipArgument>
(from the catalog plugin).
Importing Inventory
Inventory can be imported using ImportInventorySets()
, which accepts the same parameters. Entities from it's zip are processed in this order:
LocalizationEntity.*.json
InventorySet.*.json
InventoryInformation.*.json
Relationship/*.json
(InventorySet -> InventoryInformation)