Import inventory to Commerce Layer
Context
We need to import inventory updates and snapshots from Nav into Commerce Layer, required inventory attributes are:
- sku
- quantity
- stock location
It is desirable to reuse and take advantage of as much of the current infrastructure as possible.
Commerce Layer applies rate limits on their API, so we need to do as less request as possible in a short period of time. This can require to group inventory update messages. Commerce Layer core API rate limits
Import endpoints on Commerce Layer core API also have the following limits: Import limits
Decision
Nav will send each certain time inventory updates containing one or several sku inventory updates in the same message, they will also send inventory snapshots with the same format so can be handled by the same middleware process. Nav messages examples:
Inventory update:
<inventoryUpdate>
<location>DC-UK3</location>
<inventory>
<inventoryItem>
<sku>CLJ01XXBLKLRG</sku>
<available>8</available>
</inventoryItem>
<inventoryItem>
<sku>CLJ01XXBLKMED</sku>
<available>12</available>
</inventoryItem>
<inventoryItem>
<sku>CLJ01XXBLKSML</sku>
<available>6</available>
</inventoryItem>
</inventory>
</inventoryUpdate>
Inventory snapshot:
<inventorySnapshot>
<location>DC-UK3</location>
<snapshotDateTime>2023-11-12T23:00:00</snapshotDateTime>
<inventory>
<inventoryItem>
<sku>CLJ01XXBLKLRG</sku>
<available>8</available>
</inventoryItem>
<inventoryItem>
<sku>CLJ01XXBLKMED</sku>
<available>12</available>
</inventoryItem>
<inventoryItem>
<sku>CLJ01XXBLKSML</sku>
<available>6</available>
</inventoryItem>
</inventory>
</inventorySnapshot>
It will be needed to create a new inventory endpoint in Nav API Gateway to receive Nav inventory messages.
Nav XML-to-JSON lambda needs to be modified to handle both inventoryUpdate and inventorySnapshot messages, those messages need to be sent through Inventory Event Bus to new Commerce Layer inventory SQS.
A new lambda (Commerce Layer Inventory) will be in charge of processing Commerce Layer inventory SQS and send inventory updates and snapshots to Commerce Layer via import API.
