Developer forum

Forum » Ecommerce - Standard features » UnitCount on a product

UnitCount on a product

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

I had a weird issue where integrated products wouldn't return stock from locations until I saved the product in the backend first. I managed to track it down to this code in DefaultStockLevelPrrovider:

        public override double? FindStockLevel(Product product, string unitId, StockLocation stockLocation)
        {
            bool foundDefault = false;
            double valueDefault = 0.0d;
            double result = 0.0d;
            if (product.UnitCount > 0)
            {

 

This code checks product.UnitCount before it looks up the stock. In my case, the UnitCount(er) was zero in the database. When you save the product in the backend, the value is changed to 1, fixing the problem. To test my theory, I updated the counter in the database directly, cleared the product service cache and lo and behold, the stock was there.

What's the purpose of this UnitCount field? I couldn't find much on it other than "Gets or sets the unit counting" which didn't help. Is this field still relevant and if so, what value do I set it to in integration? Or can I just change it to 1 on all my products? In my database, the value is either 0 or 1, despite having lots of units, variants and stock units.

Thanks!

Imar

 


Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Bump. Anyone?

 
Morten Bengtson Dynamicweb Employee
Morten Bengtson
Reply

Hi Imar,

We are looking into this. We need to figure out if we can just remove that conditional or whether that will have a significant impact on performance.
I'm hoping that any use of Product.UnitCount can be removed/replaced, since the value of that property can easily get out of synch.

The issue has been registered as bug #19955

Until we get this solved you could ensure that [EcomProducts].[ProductUnitCounter] is set to 1 in your integration or use some notification to change the value of Product.UnitCount.
Note: The UnitCount could also be used in indexing and rendering of products, so be careful if you use it in your queries or templates.

 
Kristian Kirkholt Dynamicweb Employee
Kristian Kirkholt
Reply

Hi Imar

The bug #19955 regarding DefaultStockLevelProvider has now been fixed and released in 10.5.4 (Release Ring 1)
https://doc.dynamicweb.dev/documentation/fundamentals/dw10release/releasenotes/ringdetails/detailsring1.html

Kind Regards
Dynamicweb Care Support
Kristian Kirkholt

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Thank you both! Will this be merged down to 9 as well?

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Ping... Is this for DW 10 only or will this also come to DW 9?

Thanks!

 

You must be logged in to post in the forum