Developer forum

Forum » Development » Fetching Product Category Fields

Fetching Product Category Fields

Søren Ravn Lund
Reply

Hello,

What is the proper way of retrieving Category Fields (when not in the context of a ProductViewModel).

(Look fields.png screenshot) Where does this "Services.ProductCategoryFields.GetFields" exist? 

The "GetFieldsByCategoryId" in CategoryService is also marked as obsolete. https://doc.dynamicweb.com/api/html/7db83e1a-10a3-955d-8ab4-e6aeef35e974.htm

 

I'm using DW version 9.7.4 in the solution.

fields.png

Replies

 
Steffen Kruse Hansen Dynamicweb Employee
Steffen Kruse Hansen
Reply
This post has been marked as an answer

Hi Søren,

Sorry if this is a bit confusing. We have been working on refactoring the API around ProductCategoryFields, but we have not made all of the new Services public at this point, which is why you have some difficulties in finding the class, which the obsolete warning refers to. 
Ideally, if everything was public, you should have used Dynamicweb.Ecommerce.Services.ProductCategoryFields.GetFields(), but since it's not public your best option is to use the Dynamicweb.Ecommerce.Services.ProductCategories.GetFields() even though it's obsolete. 

The good thing is that the method will not be removed until DW10, so it shouldn't cause you any problems while on DW9.

Best regards,

Steffen

Votes for this answer: 1
 
Søren Ravn Lund
Reply

Okay - thanks for the clarification.

Merry Christmas :-)

 
Søren Ravn Lund
Reply

GetFields only gets me information about the field, but not actually the value of the field itself. I struggle to retrieve this. Any suggestions?

 
Steffen Kruse Hansen Dynamicweb Employee
Steffen Kruse Hansen
Reply
This post has been marked as an answer

Hi again Søren,

Merry Christmas to you too :)

Here the easiest way is to go directly to the product, where you have a method called 'GetCategoryValue', where you have to provide the CategoryId and the FieldId. It should give you the field value for the given product.

Best regards,

Steffen

Votes for this answer: 2

 

You must be logged in to post in the forum