Stock level Webhook put to other uses  Topic is solved

Discussions relating to the REST API of Jiwa 7.

Stock level Webhook put to other uses

Postby SBarnes » Sat Mar 20, 2021 5:31 pm

I am working on a project to integrate Jiwa with a webstore that to say the least is a fairly painful product but the customer chose it, one of the issues that exists is that to update inventory it's an all or nothing scenario and by that I mean to update an inventory item you have to update everything including the images, don't include the images and they get cleared.

Currently the inventory is being updated on a periodic basis based upon a stored last run date time and looking at when an inventory item was last updated and then the idea was to update all items at a given interval to sync the SOH, however then I thought of using the stock level webhook to avoid the update all for SOH, but the problem is both options could be fairly data intensive i.e. if an item goes on five orders one after the other that will send 5 updates one after the other and updating everything also will be a lot of data.

The idea I have is that is if I still go with update of inventory periodically but use the Stock Level Changed event to touch an inventory item and cause its last saved property to update, that way if the SOH update runs say once an hour for five sales orders with the same product it will be one update but it will also avoid the update all for SOH.

Could this be made to work?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Stock level Webhook put to other uses

Postby Mike.Sheen » Mon Mar 22, 2021 11:50 am

So you want like a webhook aggregator? Instead of sending webhooks out as they occur, instead we'd recognise the change but not send anything until a time period elapses (such as an hour or day) and at that point we send one webhook per subscription for each distinct item (say a product, for example).

Certainly do-able... I've added improvement DEV-8666 to consider this.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Stock level Webhook put to other uses  Topic is solved

Postby SBarnes » Mon Mar 22, 2021 11:56 am

I hadn't actually thought of changing Jiwa but that may not be a bad idea either, I was actually going to hook onto the same event as the api does and then simply do something like read the inventory items set the description equal to the description and then save the inventory item probably all in an async function, so the last updated was set and then at the next pass of the scheduled update it would pick up the inventory item has changed and send it to the web store.

By the way your aggregator idea may not be a bad idea in the case of a double hop where you have to go to the database to get a whole heap of data related to say a product.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175


Return to REST API

Who is online

Users browsing this forum: Google [Bot] and 6 guests