private void AddProductDescriptions(Product product, ProductViewModel sfProduct) { var displayName = sfProduct.Item.Title; var shortDescription = sfProduct.Item.Description; var longDescription = sfProduct.Item.Description; var desc = new ProductDescription { CultureCode = sfProduct.CultureCode, DisplayName = displayName, ShortDescription = shortDescription, LongDescription = longDescription }; foreach (var translation in sfProduct.CultureTranslations) { var productDescription = new ProductDescription() { CultureCode = translation.Key, DisplayName = translation.Value.Item.Title, ShortDescription = translation.Value.Item.Description, LongDescription = translation.Value.Item.Description, Product = product }; product.AddProductDescription(productDescription); } product.AddProductDescription(desc); }
private void AddProductDescriptionsForVariants(Product product, ProductVariation sfProduct) { var productDefinitionId = product.ProductDefinition.Id; var definition = _session.Query <ProductDefinition>().FirstOrDefault(x => x.ProductDefinitionId == productDefinitionId); if (definition == null) { return; } // Create product descriptions for each variant culture foreach (var translation in sfProduct.CultureTranslations) { var attributeNames = translation.Value.VariantNames.Attribute.Split(','); var attributeValues = translation.Value.VariantNames.AttributeValue.Split(','); var productDefinitionFieldNames = sfProduct.VariantNames.Attribute.Split(','); // There are no descriptions in Sitefinity at the variant level so for uCommerce we use // the concatenated variant values for display name + long & short descriptions var displayName = translation.Value.VariantNames.AttributeValue; var shortDescription = translation.Value.VariantNames.AttributeValue; var longDescription = translation.Value.VariantNames.AttributeValue; var productDescription = new ProductDescription { CultureCode = translation.Key, DisplayName = displayName, ShortDescription = shortDescription, LongDescription = longDescription }; // Create product description properties for each variant value culture for (var i = 0; i < attributeNames.Length; i++) { var fieldName = productDefinitionFieldNames[i]; var field = definition.ProductDefinitionFields.FirstOrDefault(x => x.Name == fieldName.Trim()); var productDescriptionProperty = new ProductDescriptionProperty { ProductDefinitionField = field, ProductDescription = productDescription, Value = attributeValues[i], CultureCode = translation.Key }; productDescription.AddProductDescriptionProperty(productDescriptionProperty); } product.AddProductDescription(productDescription); } }