/
Need Attention: Inventory Update Events

Need Attention: Inventory Update Events

Reference Figma Link : https://www.figma.com/proto/gP3jgDNjRUce6Z0PD5eKZY/WIP-new?page-id=5370%3A8827&node-id=5379%3A11292&viewport=696%2C528%2C0.0625&scaling=min-zoom

 

Fail/Success Message push :

{         "inventoryList": [             {                 "productId": "IRPGFNWTZ6WFZNCA",                 "sku": "00EKG3GQM92", (M)                 "variantId": "IRPGFNWTZ6WFZNCA",                 "inventory": "0"             }         ],         "externalChannelID": "CH1055",(M)         "externalWmsAccount": "eshopbox",         "externalWmsChannelName": "FLIPKART_PIDILITE_YBLR_999",         "account_id": 439,(M)         "account_slug": "pidilite",(M)         "externalWarehouseID": "COSMETIC_Bangalore",         "connectionId": 144,         "locationId": "LOC3a78e71e313c43ae8ca02b8d835becf3",         "retryable": "0",(M)         "success": false,(M)         "errorCode": "invalid_sku"(M)     }
{         "inventoryList": [             {                 "productId": "IRPGFNWTZ6WFZNCA",                 "sellerSku": "FTW800100100000",                 "sku": "00EKG3GQM92",                 "variantId": "IRPGFNWTZ6WFZNCA",                 "inventory": "0",                 "changeInStock": 0,                 "locationInventory": "0"             }         ],         "externalChannelID": "CH1055",         "publishedAt": "2021-08-09 21:56:15",         "message_id": "202108092156145585",         "externalWmsAccount": "eshopbox",         "externalWmsChannelName": "FLIPKART_PIDILITE_YBLR_999",         "account_id": 439,         "account_slug": "pidilite",         "externalWarehouseID": "COSMETIC_Bangalore",         "connectionId": 144,         "locationId": "LOC3a78e71e313c43ae8ca02b8d835becf3",         "retryable": "0",         "success": true,         "errorCode": ""     }

 

Inventory Update Topics:

  • ie_success_inventory_update (Integration enegine)

  • ie_retryable_inventory_update

  • ie_nonretryable_inventory_update

 

Events pulled from inventory topic:

[     {         "inventoryList": [             {                 "productId": "IRPGFNWTZ6WFZNCA",                 "sellerSku": "FTW800100100000",                 "sku": "00EKG3GQM92",                 "variantId": "IRPGFNWTZ6WFZNCA",                 "inventory": "0",                 "changeInStock": 0,                 "locationInventory": "0"             }         ],         "externalChannelID": "CH1055",         "publishedAt": "2021-08-09 21:56:15",         "message_id": "202108092156145585",         "externalWmsAccount": "eshopbox",         "externalWmsChannelName": "FLIPKART_PIDILITE_YBLR_999",         "account_id": 439,         "account_slug": "pidilite",         "externalWarehouseID": "COSMETIC_Bangalore",         "connectionId": 144,         "locationId": "LOC3a78e71e313c43ae8ca02b8d835becf3",         "retryable": "0",         "success": false,         "errorCode": "invalid_sku"     },     {         "inventoryList": [             {                 "productId": "IRPGFNWTZ6WFZNCA",                 "sellerSku": "FTW800100100000",                 "sku": "00EKG3GQQ91",                 "variantId": "IRPGFNWTZ6WFMCAA",                 "inventory": "0",                 "changeInStock": 0,                 "locationInventory": "0"             }         ],         "externalChannelID": "CH1055",         "publishedAt": "2021-08-09 21:56:15",         "message_id": "202108092156145585",         "externalWmsAccount": "eshopbox",         "externalWmsChannelName": "FLIPKART_PIDILITE_YBLR_999",         "account_id": 439,         "account_slug": "pidilite",         "externalWarehouseID": "COSMETIC_Bangalore",         "connectionId": 144,         "locationId": "LOC3a78e71e313c43ae8ca02b8d835becf3",         "retryable": "0",         "success": false,         "errorCode": ""     } ]

 

Case 1: Success

Topic : success_inventory_update

 

  • Create endpoint to pull success inventory updates event

  • Pull events in batches of 200 while message is empty

  • Loop on the events and prepare data for success inventory updates queue

    • Prepare Esin to externalChannelID Map

  • Push data in batches of 200 to task queue.

    { "esinToexternalChannelID" : { "TestEsin1": "CH1046", "TestEsin2": "CH1047" } }
  • Listen to data in Taskqueue

  • Fetch Products from MongoDb using Esin, in batches.

    • Check if the Esin is present in the MongoDB, if yes, then only we will proceed further, else end the flow.

      • Check if the externalChannelID is present in the inventoryUpdateFailures list. 

      • if not present then, exit the flow

    • if present then, remove the externalChannelID from the inventoryUpdateFailures List

    • Prepare a list of updated ESINs.

    • Bulk Update the changes on MongoDb and Algolia

 

 

Case 2 :  Retryable and Non-retryable 

Topics : retryable_inventory_update and nonretryable_inventory_update

 

  • Create an endpoint to pull Retryable and Non-retryable inventory events from the topic

  • Pull events in batches of 200 while message is empty

  • Loop on the events and prepare data for success = false inventory updates

    • Prepare Esin to externalChannelID Map

    • Prepare Esin to Error_code Map

  • Push data in batches of 200 to the task queue.

    { "esinToexternalChannelID" : { "TestEsin1": "CH1046", "TestEsin2": "CH1047" }, "esinToErrorMap" : { "TestEsin1": "invalid_sku", "TestEsin2": "authorization_error" } }
  • Listen to data in Taskqueue

  • Fetch Products from MongoDb using Esin, in batches.

    • Check if the Esins are present in the MongoDB, if yes, then only we will proceed further, else end the flow.

  • Loop on the products and Make a list of products marked unavailable and available on the given channels.

Case A: If the product is marked unavailable on the channel

  • Check if inventoryUpdateFailures list, contains externalChannelID 

  • If true, Do Nothing 

  • If false, Add key : externalChannelID to inventoryUpdateFailures

{     "inventoryUpdateFailures": [         "CH4591", "CH4900"     ] }
  • Prepare a list of updated ESINs.

  • Bulk Update the changes on MongoDb and Algolia

 

Case B:  product is available on channel

  • Mark products unavailable

  • Check if inventoryUpdateFailures list, contains externalChannelID

  • If true, Do Nothing 

  • If false, Add key : externalChannelID to inventoryUpdateFailures

{     "inventoryUpdateFailures": [         "CH4591"     ] }
  • Bulk Update the changes on MongoDb and Algolia

 

Related content