Bulk update inventory using Service API?

Vote:
 

We are starting a new Commerce project, and are currently planning our integration strategy. We would like to use the Service API as much as possible to have a clean API towards Commerce. But I'm a bit concerned if this is the right approach.

Right now we are looking at inventory. Our inventory is managed by the ERP system, but for performance reasons we would like to syncrhonize inventory with Commerce often. Perhaps every 10 minutes if this is possible.

The only Inventory update API's I can see from the documentation are:

POST post/episerverapi/commerce/entries/{entryCode}/inventories

PUT put/episerverapi/commerce/entries/{entryCode}/inventories/{warehouseCode}

But both of these API's seem to update 1 inventory for 1 product. Are there no bulk operations for updating inventory? Or am I just looking the wrong place?

What then is the recommended approach to update inventory for many products at the same time?

Thank you for your help.

Regards

Anders

#322926
Edited, May 31, 2024 6:36
Vote:
 

Hi Anders

For inventory bulk update I wouldn't go with Service API, instead you can use IWarehouseInventoryService.Save(IEnumerable<IWarehouseInventory> inventories)  method that accepts a list of inventories. Alternatively, you can use IInventoryService.Save(IEnumerable<InventoryRecord> records) as well

#322936
Edited, May 31, 2024 10:43
Vote:
 

Just as Vincent said, you can easily add a new endpoint to update inventories of multiple SKUs at once (however, arguably that's no longer RESTful). The SKU (entry) is the resource and inventories and prices are parts of that resource. It's be tricky if you design that endpoint, but if you ignore some RESTful rules then it's doable. I do think that a scheduled job is a better fit for such job - both for inventories and prices. Just one note: IWarehouseInventoryService and IWarehouseInventory are obsolete and removed in later version, you should stick with IInventoryService/InventoryRecord

#322942
May 31, 2024 15:25
Vincent - Jun 03, 2024 1:22
Thanks for the extra info. I'm a bit out of date on latest Commerce 14 :) and didn't realize IWarehouseInventoryService are obsolete
Vote:
 

Thank you for your help. I guess that is the way to go.

I guess I was just hoping that the Service API could do more than it actually can.

#323024
Jun 03, 2024 5:49
Quan Mai - Jun 03, 2024 10:12
it's a good question actually. as I said it's a matter of design principles - would you adhere to the RESTful rules or would you be more "Relaxed". we picked the former and it was a conscious decision. If there is a nice, simple way to make bulk import of inventories and prices, we'd definitely do that :)
arguably you can use the catalog import for this, but it's probably a not very intuitive way :)
Vote:
 

@Quan Mai: Well, I don't know if the Catalog Import is very RESTful. But it can be very useful :)
Can I use the Catalog Import to update inventory, by only specifying Code of the Entry and the updated WarehouseInventory element(s)?

It may not be intuitive, but if it works and performs well, this may be what we need.

We probably need to invest in understanding the Catalog.xml format anyway to update our product catalog from our PIM system. So if we can also use it to update inventory based on updates from ERP, this may be ok. But we will need separate integration flows (with separate data), since catalog and inventory updates will come from separate systems.

We don't expect to store prices in Optimizely commerce, since our price logic is completely custom for our B2B scenario. We have customer-specific prices on most of the items, and it must match the business logic from the ERP system.

#323039
Jun 03, 2024 10:51
Quan Mai - Jun 03, 2024 11:04
in a sense the Catalog is a resource. but yes, we can't always follow the rules strictly :)
yes, you can import pure inventories/prices. just take any sample catalog you have and strip all catalog information and leave just price and inventory information. For example https://github.com/episerver/Quicksilver/blob/master/Sources/EPiServer.Reference.Commerce.Site/App_Data/Catalog_Fashion.zip
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.