private void AddProductDefinitionFieldIfDoesntExist(ProductDefinition definition, string name, string typeName, bool displayOnWebsite, bool variantProperty, bool promotoToFacet, string displayName) { if (definition.GetDefinitionFields().Any(f => f.Name == name)) { return; } var field = ProductDefinitionField.SingleOrDefault(f => f.Name == name && f.ProductDefinition.ProductDefinitionId == definition.ProductDefinitionId) ?? new ProductDefinitionFieldFactory().NewWithDefaults(name); field.Name = name; field.DataType = DataType.SingleOrDefault(d => d.TypeName == typeName); field.Deleted = false; field.Multilingual = false; field.DisplayOnSite = displayOnWebsite; field.IsVariantProperty = variantProperty; field.RenderInEditor = true; field.Facet = promotoToFacet; //Helpers.DoForEachCulture(language => // { // if (field.GetDescription(language) == null) // field.AddProductDefinitionFieldDescription(new ProductDefinitionFieldDescription { CultureCode = language, DisplayName = displayName, Description = displayName }); // }); definition.AddProductDefinitionField(field); definition.Save(); }
private void AddProductDefinitionFieldIfDoesntExist(ProductDefinition definition, string name, string typeName, bool displayOnWebsite, bool variantProperty, bool promotoToFacet, string displayName) { if (definition.GetDefinitionFields().Any(f => f.Name == name)) { return; } var field = ProductDefinitionField.SingleOrDefault(f => f.Name == name && f.ProductDefinition.ProductDefinitionId == definition.ProductDefinitionId) ?? new ProductDefinitionFieldFactory().NewWithDefaults(name); field.Name = name; field.DataType = DataType.SingleOrDefault(d => d.TypeName == typeName); field.Deleted = false; field.Multilingual = false; field.DisplayOnSite = displayOnWebsite; field.IsVariantProperty = variantProperty; field.RenderInEditor = true; field.Facet = promotoToFacet; definition.AddProductDefinitionField(field); definition.Save(); }