Developer forum

Forum » Development » Best future proof method for querying products by custom field?

Best future proof method for querying products by custom field?

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I need to build some code that is supposed to enrich some products based on data from external sources.

I am basically building an Add-in that should loop over a list of products and adjust ProductCategoryField values based on some external data.

There's been a lot of changes lately in how interaction with products via API is happening and I want to make sure that whatever code I am building now is going to be future-proof.
Therefore, I would like to find out the best method to identify a product based on a ProductField value and also the best method for adding/editing productCategoryFieldValues.

I am guessing I should use Dynamicweb.Ecommerce.ProductService but there are a lot of methods in there for querying products and some of them are marked as Obsolete.

Can somebody suggest the best approach?

Thank you,
Adrian


Replies

 
Morten Snedker Dynamicweb Employee
Morten Snedker
Reply

Hi Adrian,

Luckily that is quite simple:
The Product object has a SetCategoryValue(string CategoryId, string FieldId, object value) method: https://doc.dynamicweb.com/api/html/1d73e2f0-f3db-07e8-75ac-83efef773c0d.htm

BR
Snedker

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Morten,

Thank you very much.

I was confused by the name of the method. I was expecting something like SetCategoryFieldValue :)

Nevertheless, it's pretty straightforward and definitely very useful.

Thank you,
Adrian

 

You must be logged in to post in the forum