InventoryUpdate event

Vote:
 

Hello,

I have implemented the InventoryUpdated event as described here: https://world.episerver.com/documentation/developer-guides/commerce/events/inventory-events/

The events are raised as expected, however i need to know what the update to the inventory was.

If i understand the documentation correctly, it seems this information should be in the sender object, however i do not see any usefull information on the object when i debug it. Is there some casting or transformation necessary and if so how do i do that?

I use Commerce version 11.8.1

/jon

#190422
Apr 10, 2018 17:49
Vote:
 

Try casting sender to IEnumerable<InventoryRecord>

#190427
Apr 10, 2018 20:51
Vote:
 

I tried that, but it only becomes null, my code was this:

private void RemoteInventoryUpdated(object sender, InventoryUpdateEventArgs inventoryUpdatedEventArgs)

{
    var inventory = sender as IEnumerable<InventoryRecord>;

    //do stuffs

}

#190435
Apr 11, 2018 10:17
Vote:
 

I'm not entirely sure but when you listen to a remote event, the sender is not "transmitted".

In future version of Commerce, the args will contain the delta changes to the inventory system. 

#190436
Apr 11, 2018 10:20
Vote:
 

I see, do you know if there is another way to find the delta from within the event-hook?

#190438
Apr 11, 2018 10:35
Vote:
 

Unfortunately no, it needs changes in the core, so it requires newer version from us. As always, it's good thing to keep up to date https://vimvq1987.com/why-you-should-upgrade-to-the-latest-version/ 

#190439
Apr 11, 2018 10:39
Vote:
 

Quan - since requesting inventory via the IInventoryService in the event hook will return the "old" inventory records, does that mean that there's no way to get the updated inventory status on the same request? Any suggestion for a work around for this?

#190475
Apr 11, 2018 12:31
Vote:
 

Technically you can get the new inventory records from database. Yes it does not sound super effective, but it works, and the records will be cached for later uses anyway 

#190500
Apr 11, 2018 13:29
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.