Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Get current (not cached) inventory responses

Vote:
 

Hello,

I'm using the new IInventoryService, the following code:

var response = _inventoryService.Request(new InventoryRequest()
{
   RequestDateUtc = DateTime.UtcNow,
   Items = new[]
   {
       new InventoryRequestItem
       {
          RequestType = InventoryRequestType.Purchase,
          CatalogEntryCode = myVariant.Code,
          Quantity = quantity,
          WarehouseCode = warehouseCode,
          ItemIndex = 0
        }
   }
});

The inventory rows returned appear to be cached - I've tried disabling entry caching in the ecf.catalog.config but no luck.

Any tips :)?

Thanks,

Dean

#152032
Edited, Aug 12, 2016 18:36
Vote:
 

Hi,

The cache system in Inventory System - or in other subsystems in Commerce - must be invalidated when there are changes made. The code you used must return up-to-date values. Otherwise it's a bug. Which changes did you make and how?

Regards,

/Q

#152038
Aug 12, 2016 21:19
Vote:
 

Hi Quan,

Thanks for the response!

So I used Commerce Manager > Warehouse Inventory tab under a variationContent, I removed the preorderquantityavailable and backorderquantityavailable (they were set to 10 from a previous edit), and set the purchaseavailablequantity to 10 (this was 0).

Each time I run the above code - just to check inventory values (I'll be using the PurchaseOrPreorder request type I think) it still returns the previous edit, 0/10/10.

Is the way I posted above a reasonable way to retrieve if products are available etc? The activities aren't accessible so I can't call them - having to replicate the activity behaviour manually?

thanks!

Dean

#152040
Aug 12, 2016 21:57
Vote:
 

Hi,

Firstly make sure your site is properly configured so cache validation between Commerce Manager and front-end (CMS) site is working. If you edit an entry in Commerce, does the change show up in Catalog UI and vice versa?

And looks closely to your code - it is trying to make some requests - aka changes - to the inventory system. If you want to check inventory values, use IInventoryService.Get instead.

Note that IInventoryService works with InventoryRecord, it's not exactly the values represented in CM. CM work with WarehouseInventory record - which is mapped from InventoryRecord, but not necessary the same.

/Q

#152042
Aug 13, 2016 9:48
Vote:
 

Hi Quan,

thanks for the update! Can confirm it was definitely user error :P sorry for wasting your time!

IInventoryService.Get is working perfectly - thanks!

#152071
Aug 15, 2016 16:36
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.