Developer forum

Forum » Ecommerce - Standard features » Where is reserved stock stored?

Where is reserved stock stored?

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

I have a batch job that imports stock from an XML file every 30 minutes. Would this create problems with the reserved stock leading DW to believe there's more than there really is? For example:

  1. Initial stock is 30
  2. I add 10 to the cart, leaving 20 as the new available stock for the next user.
  3. The import job runs and sets stock to 30 again.

Would that be an easy or doesn't the actual stock level change until the order is completed?

Or another scenario:

  1. Initial stock is 30
  2. I add 10 to the cart, leaving 20 as the new available stock for the next user.
  3. The import job runs and sets stock to 5.

Will that be a problem? Do I still have the reserved 10 or does Dynamicweb during checkout look at the actual stock + the ones that are reserved by others?

And finally, where are the reserved items stored? In memory?

Thanks,

Imar


Replies

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

Reserved stock is 'just' in mem on the solution. It is used to provide the "AvailableStock" tag on the product. That number comes from stock in DB - reserved stock for the product in mem.

So if you change the DB stock, it will have no affect - no problem. If 10 is reserved and you change from 30 to 5 in the DB, available will of course be -5. That is fine.

When the checkouthandler is starting in the last cart step, the cart is converted to an order (complete=false) and at that time the amount of a product in the cart is checked against the level in the DB again (it could have changed in the meantime).

So both your scenarios should work.

BR Nicolai

Votes for this answer: 1
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Great, thank you!

Imar

 
Adrian Ursu
Reply

Hi Nicolai,

Is there any way to access the Reserved Stock (or Available stock) via the API inside a product object?

I am using this to find the Product:

Dynamicweb.eCommerce.Products.Product eComProduct = Dynamicweb.eCommerce.Products.Product.GetProductByID(product.ID);

Thanks,

Adrian

 
Nicolai Høeg Pedersen
Reply

eCommerce.Frontend.Cart.ProductReserve.GetReservedAmount(Product.ID, Product.VariantID)

 
Adrian Ursu
Reply

Thanks a lot!

 
Adrian Ursu
Reply

Looks that I am not done yet.

I get these errors:

 

Line 70: 'Dynamicweb.eCommerce.Frontend.Cart.ProductReserve' is inaccessible due to its protection level
Line 70: 'Dynamicweb.eCommerce.Frontend.Cart.ProductReserve' does not contain a definition for 'GetReservedAmount'
 
Adrian Ursu
Reply

The reason I need this is that we are using ajax to post to cart and if the product is not available, it cannot be added to cart and we cannot notify the user about the availability.


In the product list we are retrieving the products with the above statement because wee need first to filter out the groups based on the customer number which makes it hard to access both groups, subgroups and products in the same page. I am not sure why the GetLoop("Products") is not available in the groups loop but that's what happens.

I believe if we manage to list products with the regular ProductLoop, the AvailableAmount tag is accessible. 

Any alternative ideea would be welcomed.

Thanks,

Adrian

 

You must be logged in to post in the forum