Developer forum

Forum » Ecommerce - Standard features » Ensure unique values for ProductNumber

Ensure unique values for ProductNumber

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

What would be the best way to implement a check for duplicates on the ProductNumber?

What I want is to avoid mistakes when defining products. The ProductNumber should be unique.

Thank you,

Adrian


Replies

 
Shiwanka Chathuranga Dynamicweb Employee
Shiwanka Chathuranga
Reply

For this, we have used Product.BeforeSave Notificationsubscriber and StopExecution

https://doc.dynamicweb.com/api-docs#article=59a82bc6-cce3-1592-2901-70342df8694f

But not sure is it the best solution

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi,

Thank you very much for the suggestion.

That's what I had in mind as well. I was curious if there would be another way of handling it but I can surely use your suggestion.

Thank you,
Adrian

 

 
Lars Larsen
Lars Larsen
Reply

Hi Shiwanka & Adrian

I have tried your suggestion using Product.BeforeSave Notificationsubscriber and StopExecution. When saving a product the notification subscriber triggers and the updated product data is not saved in the database. But the data seems to be saved in the cache. This can be seen when one has updated some product data and hits save and close. When editing the same product again the data updated is shown, eventhough it's not saved in the database. How did you manage to fix this issue?

 
Shiwanka Chathuranga Dynamicweb Employee
Shiwanka Chathuranga
Reply

can you try this

            ProductService productService = new ProductService();
            productService.ClearCache();

 

You must be logged in to post in the forum