Developer forum

Forum » Development » Prepare StockLevelProvider

Prepare StockLevelProvider

Duncan Janssen
Reply

For the live products prices, there is a prepare Prices function. You also get a list of the selection products where I can get the ProductIds from, for example, a product overview.

We need to have something similar for our client but then for the stock levels. I use the StockLevelProvider to change the values of the stockLevels.

Is there something similar for the stockLevelProvider to get a selection of the products?


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Duncan

There is no similar approach as prepareprices.

But you have other options.

If you use product catalog for viewmodels, you can use a notification subscriber:

Notifications.Ecommerce.ProductCatalog.OnBeforeProductListRender

It will give you this argument:

Notifications.Ecommerce.ProductCatalog.OnBeforeProductListRenderArgs

It contains a list of all the product autoids that is about to get rendered, and then you can get the products using product service (products are already cached)

Then query the inventory from ERP in one go for all the products and store the response information in a threadstatic, request.items or memory cache and use that cache in your stocklevel provider to retrieve the value for each product.

BR Nicolai

Votes for this answer: 2
 
Duncan Janssen
Reply

Hi Nicolai,

Thanks for the answer. We now use the notification subscriber to get a list of all rendered products.

Whit kind regards,

Duncan

 

You must be logged in to post in the forum