Developer forum

Forum » Templates » Group CategoryFields

Group CategoryFields

Tymen NNM
Reply

I'm trying to retrieve the value / labels of all product category fields from a product group inside a product list page.

I can loop trough the category fields  by calling GetLoop("GroupCategoryFields") but the values seems empty while other fields like id and label are filled.

For example:

        @foreach(var field in GetLoop("GroupCategoryFields")){

            var label = field.GetString("Ecom:Group.CategoryField.Label");
            var fieldId = field.GetString("Ecom:Group.CategoryField.ID");
            var value = field.GetString("Ecom:Group.CategoryField.Value");
  
          }

How can i get the values of a group categoryfield?


Replies

 
Nicolai Høeg Pedersen
Reply

Hi Tymen

I need to see your template and need to know in what context you need to render the value.

Product Category fields are only available on a product - you say that you try to get it for a product group?

Product category fields has their values on a product - so when rendering a product, you can get hold of a value for that product category field. It is right that you on a product group defines the product category - and on the group you can then loop which fields are available for products in that group. But the group it self does not have a value for the fields (the values are specified on the products in that group)

Hope this makes sense.

BR Nicolai

 
Tymen NNM
Reply

When i use to TemplateTags() to display all available tags, it does display the product category values binded to the group.

For example:

Ecom:Product.CategoryField.OptiBean.Inhoud.Value 2 liter
 
Tymen NNM
Reply

Basically, what we are trying to do is the following (within the context of a product group):

@foreach(var field in GetLoop("GroupCategoryFields"))
{
    var label = field.GetString("Ecom:Group.CategoryField.Label"); 
    var fieldId = field.GetString("Ecom:Group.CategoryField.ID"); 
    var value = field.GetString("Ecom:Group.CategoryField.DefaultValue"); 

But the DefaultValue is not displayed. Label and FieldId are displayed just fine. The DefaultValue does have a value set in the ECommerce backend. What are we missing?

 
Oleg Rodionov
Reply
This post has been marked as an answer

Hi Tymen,

Please, follow the description regarding the same tag but for a specific product - http://templates.dynamicweb.com/eCommerce/Dynamicweb-eCommerce-template-tags/Product-Catalog/Product-detail/EcomProduct-CategoryField-ProductCategoryGroup-Field-DefaultValue.aspx. As you can see the tag is filled for fields of type list-box has the selected option, it's true for GroupCategoryFields loops within Groups as well.

BR, Oleg QA

Votes for this answer: 1

 

You must be logged in to post in the forum