Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Service API: Issue with metadata in different languages

Found in

EPiServer.ServiceApi 5.0.0

Fixed in

EPiServer.ServiceApi 5.0.1

(Or a related package)

Created

Jun 15, 2018

Updated

Oct 12, 2018

State

Closed, Fixed and tested


Description

Product version: EPiServer.ServiceApi.Commerce 5.0.0

PIM-system fails.

The problem occurs when you fetch an entry with all values from all languages. If one language does not have a value, it skips all subsequent languages. For example, you have an entry with 10 languages: SV, DA, DE, EN, ES, FI, FR, KO, NL, NO. All languages have a value for the metadata "DisplayName" except ES.

When I fetch this entry, and look at "DisplayName" in the meta fields, I only see values for SV, DA, DE, EN.
Because ES doesn't have a value, it also skips FI, FR, KO, NL, NO.

Here is where the error occurs:

EPiServer.ServiceApi.Commerce.Controllers.Catalog.Construction.MetaDataModelFactory:

protected List<MetaFieldData> GetValues(MetaField metaField, IEnumerable<CatalogContentBase> contents)
 
{
    List<MetaFieldData> list = new List<MetaFieldData>();
    foreach (CatalogContentBase content in contents)
    {
        object obj = content.Property[metaField.Name]?.Value;
        if (obj == null)
        {
            *return list;
*
        }
        ...
}

The error is the bold line. The return; breaks the foreach-loop and only returns values before this occurred.
It should be a continue; instead.