Developer forum

Forum » Development » Groups language on product object doesnt match product language

Groups language on product object doesnt match product language

Kevin Steffer
Kevin Steffer
Reply

I have a weird behavior on multiple language ecommerce.

When I get a product with the ProductService or old way by specifying LanguageId parameter I thought that getting the Groups on the object would have the same language.

Bare in mind that this code is executed in Backend context or without having set the ecommerce language on your website settings. 

But it doesn't the groups are all in the solutions default language!

Shouldn't the groups follow the language id of the product itself?

The code:

Response.Write("Calling: Dynamicweb.Ecommerce.Services.Products.GetProductByNumber(\"1001-blue\", \"LANG2\")" + System.Environment.NewLine);
var product = Dynamicweb.Ecommerce.Services.Products.GetProductByNumber("1001-blue", "LANG2");
Response.Write("Found product: Name: "+ product.Name +", ProductId: "+ product.Id + ", LangID: "+ product.LanguageId + System.Environment.NewLine);
Response.Write("Now calling product.Groups" + System.Environment.NewLine);
foreach (var group in product.Groups) {
      Response.Write("Group Name: "+ group.Name +", Group LanguageID: "+ group.LanguageId + System.Environment.NewLine);
}

This produces this output


Calling: Dynamicweb.Ecommerce.Services.Products.GetProductByNumber("1001-blue", "LANG2")
Found product: Name: Mit Product updated, ProductId: PROD1, LangID: LANG2
Now calling product.Groups
Group Name: Beds, Group LanguageID: LANG1

Replies

 
Nicolai Pedersen
Reply

Hi Kevin

I understand the confusion. The Groups property of the product uses default language because groups might not have been translated. So it gives a collection of groups available, translated or not.

So after you get the collection of groups, you have to use the groupservice to get the translated versions if needed.

These APIs are undergoing some changes to seperate logic a bit more and to be more explicit - but it is a giant task, so it will take some time.

BR Nicolai

 
Kevin Steffer
Kevin Steffer
Reply

Thanks - it was just causing a bug in my custom solution since because I was looking for a field-value on the group, and I got the value from the default language version of the group and not the value from the language of the product language - ARGHF :(

But anyway - great it has your attention.

 

You must be logged in to post in the forum