Developer forum

Forum » Development » Get ProductCategoryField options through API

Get ProductCategoryField options through API

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

Is there an easy way to access all options of a specific ProductCategoryField via the API?

Thank you,

Adrian


Replies

 
Morten Snedker Dynamicweb Employee
Morten Snedker
Reply

Hi Adrian,

Are you looking for something like

var cf = Dynamicweb.Ecommerce.Services.ProductCategoryFields.GetFieldById("[CategoryId]", "[FieldId]");
foreach (var option in cf.FieldOptions)
{
   string name = option.Name;
   string optionValue = option.Value;
}

BR
Snedker

 

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Morten,

Yes!. That should do it.

Is there any reason why this entire Dynamicweb.Ecommerce.Services section is not visible in the API documentation? Or am I looking in the wrong place?

Thank you,
Adrian

 
Morten Snedker Dynamicweb Employee
Morten Snedker
Reply

Hi Adrian,

It is there. If you navigate to https://doc.dynamicweb.com/api-docs and unfold Dynamicweb 9 > Dynamicweb.Ecommerce, you will find the Services class: https://doc.dynamicweb.com/api-docs#article=33d1e8f0-8a99-1118-98b8-b214644650ef.

BR
Snedker

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Morten,

Thank you very much. I am not sure how I have missed it.

Thank you, I will bookmark it :)

Adrian

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Morten,

Is there also a way to set the Options of a ProductCategoryField?

Thank you,

Adrian

 

You must be logged in to post in the forum