How do we set a multifield value through litium connect

how should we set a multi field value through litium connect import, fields?

Litium version: 7.7.1

1 Like

We don’t support MultiField import for the moment.

It is possible to import multifields in Litium 8. I think that works for litium 7 also.
The trick is that you need to set AreaType. This is how we did it in one project:

                    var list = articles.Fields.Select(article =>
                    {
                        var fieldList = new Dictionary<string, Dictionary<string, object?>>();

                        fieldList.Add("Variant_gm", new Dictionary<string, object?>() { ["*"] = ReplaceSpace(article.Fields.GetStringValue("ProductSku")) });
                        fieldList.Add("BaseArticleNumber_gm", new Dictionary<string, object?>() { ["*"] = ReplaceSpace(article.Fields.GetStringValue("BaseArticleNumber")) });
                        fieldList.Add("IsMainProduct_gm", new Dictionary<string, object?>() { ["*"] = article.Fields.GetBoolValue("Headarticle") ?? false });
                        fieldList.Add("VariantBundlePrice_gm", new Dictionary<string, object?>() { ["*"] = article.Fields.GetDecimalValue("BasePrice") });
                        fieldList.Add("QuantityBundle_gm", new Dictionary<string, object?>() { ["*"] = article.Fields.GetIntValue("Quantity") });
                        return new
                        {
                            AreaType = "Litium.Products.ProductArea, Litium.Abstractions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=093d4a638630e7c5",
                            Fields = fieldList
                        };
                    });

                    variantFieldSet.Add(new Field() { FieldDefinitionId = "BundleProducts_gm", Value = list.ToArray() });

                    variant.Fields = variantFieldSet;
1 Like

I think you misunderstood the question, a MultiField field is a type of field that contains various types of fields.

yes, thats what I mean. The field we are importing with this looks like this:

definitions.Add(new FieldDefinition(GardsmanProductsFieldNameConstants.BundleProductsGm, SystemFieldTypeConstants.MultiField)
{
Option = new MultiFieldOption
{
IsArray = true,
Fields = new List()
{
GardsmanProductsFieldNameConstants.VariantGm,
GardsmanProductsFieldNameConstants.BaseArticleNumberGm,
GardsmanProductsFieldNameConstants.QuantityBundleGm,
GardsmanProductsFieldNameConstants.IsMainProductGm,
GardsmanProductsFieldNameConstants.VariantBundlePriceGm,
}
}
});

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.