Developer forum

Forum » Ecommerce - Standard features » Update Stock
Tin Ma Ma
Reply

Hi ,

Ecommerce > Product Catalog >  Product List show stock 0. but go in product detail, show stock 99999 . Then check in database , the stock is zero.
And also this product is still showing in website.

Please advise.

https://www.loom.com/share/c66c84cbc92c4e2a9aa514ead06958d9


Regards,
Tin Ma Ma


Replies

 
Morten Snedker Dynamicweb Employee
Morten Snedker
Reply

Hi Tin Ma Ma,

Do you have a public URL I can access? I tried https://web-uat95.twgtea.com/admin, but didn't manage go get at timely response from the site.

Best regards
Morten Snedker

 
Tin Ma Ma
Reply

Dear Morten,

Could you please check in https://twg-uat.dynamicwebapac.com site?


Thanks and Regards,

Tin Ma Ma
 

 
Morten Snedker Dynamicweb Employee
Morten Snedker
Reply

On the given website the stock is presented just fine. I also changed the stock from 9999999 to 9999998, and the change was also presented just fine.

https://www.screencast.com/t/ZFjaQkMtDEx5

Let me have a comment.

Best regards
Morten Snedker | Helpdesk

 

 
Tin Ma Ma
Reply

Dear Morten,

Kindly check the following scenario :

1. click Stock Not Available checkbox in Ecommerce >> Product Catalog >> Product List >> Edit Product
2. run Product Stock Update schedule job
3. check Ecommerce >> Product Catalog >> Product List, the stock is 0 but in Ecommerce >> Product Catalog >> Product List >> Edit Product, the stock is 99999999.
4. go to the frontend, the product can still buy

please check the attached images.

Thanks and Regards,

Tin Ma Ma

 

Step1.png Step2.png Step3.png Step4.png Step5.png
 
Nicolai Pedersen
Reply

The  "Stock Not Available" field is a custom field you created and must be handled by your own implementation.

I think you need to look into your implementation on this site to fix the issue.

BR Nicolai

 
Morten Snedker Dynamicweb Employee
Morten Snedker
Reply

Hi Tin Ma Ma,

I see that it is a custom made job that you're running. Two questions:

  1. How do you update the product code-wise?
  2. Are you updating all products, or is it a delta update?

Best regards
Morten Snedker

 
Tin Ma Ma
Reply

Dear Morten,

Thank you for your reply.

Question 1: Use SQL Update query


Here is my code

 public class ProductStockScheduleTaskAddin : BaseScheduledTaskAddIn
    {
        /// <summary>
        /// Main method in ScheduledTask Addin - is run when scheduled Task is run
        /// </summary>
        /// <returns></returns>
        public override bool Run()
        {
            bool ret = true;
          
            Dynamicweb.Data.Database.ExecuteNonQuery("UPDATE EcomProducts SET ProductStock=0 WHERE StockNotAvailable=1");
            Dynamicweb.Data.Database.ExecuteNonQuery("UPDATE EcomProducts SET ProductStock=9999999 WHERE StockNotAvailable=0");          

            return ret;
        }
    }

Question 2: It is delta update


Regards,

Tin Ma Ma

 

 
Morten Snedker Dynamicweb Employee
Morten Snedker
Reply

Hi Tin Ma Ma,

Sorry for the late reply: you're running into a caching issue. You need to clear the product cache upon updating: https://doc.dynamicweb.com/api/html/8096d029-ca46-5f65-49f0-cc0ac8a71be2.htm

Hope this helps.

Best regards
Morten Snedker

 
Arker Soe
Arker Soe
Reply

Hi Nicolai and Morten, 

Can we clear cache only on specific product?

The scenario is we are considering to clear cache only on products which include in order after checkout completed.

Could you please advice?

With thanks !

 

You must be logged in to post in the forum