public void Update_Sunglasses_Style_Property_ProductType() { var productTypeName = "Sunglasses"; var filter = string.Format("name eq '{0}'", productTypeName); var productTypeHandler = new MozuDataConnector.Domain.Handlers.ProductTypeHandler(); var productTypes = productTypeHandler.GetProductTypes(_apiContext.TenantId, _apiContext.SiteId, _apiContext.MasterCatalogId, 0, 20, null, null).Result; var existingProductType = productTypes.SingleOrDefault(a => a.Name == productTypeName); if (existingProductType != null) { var attributeHandler = new MozuDataConnector.Domain.Handlers.AttributeHandler(); var attributeStyle = attributeHandler.GetAttributes(_apiContext.TenantId, _apiContext.SiteId, _apiContext.MasterCatalogId, 0, 1, null, "attributeFQN eq 'tenant~sunglass-style'").Result.First(); AttributeInProductType productTypePropertyStyle = new AttributeInProductType() { AttributeFQN = attributeStyle.AttributeFQN, IsInheritedFromBaseType = false, AttributeDetail = attributeStyle, IsHiddenProperty = false, IsMultiValueProperty = true, IsRequiredByAdmin = false, Order = 0, VocabularyValues = new System.Collections.Generic.List <AttributeVocabularyValueInProductType>() }; var productTypePropertyStyleValues = "Pilot|Rectangle|Rimless"; var seq = 30; foreach (var value in productTypePropertyStyleValues.Split('|')) { productTypePropertyStyle.VocabularyValues.Add(new AttributeVocabularyValueInProductType() { Value = value, Order = 0, VocabularyValueDetail = new AttributeVocabularyValue() { Content = new AttributeVocabularyValueLocalizedContent() { LocaleCode = "en-US", StringValue = value }, Value = value, ValueSequence = seq++ } }); } existingProductType.Properties.Add(productTypePropertyStyle); var newProductType = productTypeHandler.UpdateProductType(_apiContext.TenantId, _apiContext.SiteId, _apiContext.MasterCatalogId, existingProductType).Result; } }
public void Update_Sunglasses_Protection_Property_ProductType() { var productTypeName = "Sunglasses"; var filter = string.Format("name eq '{0}'", productTypeName); var productTypeHandler = new MozuDataConnector.Domain.Handlers.ProductTypeHandler(); var productTypes = productTypeHandler.GetProductTypes(_apiContext.TenantId, _apiContext.SiteId, _apiContext.MasterCatalogId, 0, 20, null, null).Result; var existingProductType = productTypes.SingleOrDefault(a => a.Name == productTypeName); if (existingProductType != null) { var attributeHandler = new MozuDataConnector.Domain.Handlers.AttributeHandler(); var attributeProtection = attributeHandler.GetAttributes(_apiContext.TenantId, _apiContext.SiteId, _apiContext.MasterCatalogId, 0, 1, null, "attributeFQN eq 'tenant~sunglass-protection'").Result.First(); AttributeInProductType productTypePropertyProtection = new AttributeInProductType() { AttributeFQN = attributeProtection.AttributeFQN, IsInheritedFromBaseType = false, AttributeDetail = attributeProtection, IsHiddenProperty = false, IsMultiValueProperty = false, IsRequiredByAdmin = false, Order = 0 }; existingProductType.Properties.Add(productTypePropertyProtection); var newProductType = productTypeHandler.UpdateProductType(_apiContext.TenantId, _apiContext.SiteId, _apiContext.MasterCatalogId, existingProductType).Result; } }
public void Update_Sunglasses_Color_Options_ProductType() { var productTypeName = "Sunglasses"; var filter = string.Format("name eq '{0}'", productTypeName); var productTypeHandler = new MozuDataConnector.Domain.Handlers.ProductTypeHandler(); var productTypes = productTypeHandler.GetProductTypes(_apiContext.TenantId, _apiContext.SiteId, _apiContext.MasterCatalogId, 0, 20, null, null).Result; var existingProductType = productTypes.SingleOrDefault(a => a.Name == productTypeName); if (existingProductType != null) { var attributeHandler = new MozuDataConnector.Domain.Handlers.AttributeHandler(); var attributeColor = attributeHandler.GetAttributes(_apiContext.TenantId, _apiContext.SiteId, _apiContext.MasterCatalogId, 0, 1, null, "attributeFQN eq 'tenant~color'").Result.First(); AttributeInProductType productTypeOptionColor = new AttributeInProductType() { AttributeFQN = attributeColor.AttributeFQN, IsInheritedFromBaseType = false, AttributeDetail = attributeColor, IsHiddenProperty = false, IsMultiValueProperty = false, IsRequiredByAdmin = false, Order = 0, VocabularyValues = new System.Collections.Generic.List <AttributeVocabularyValueInProductType>() }; productTypeOptionColor.VocabularyValues.Add(new AttributeVocabularyValueInProductType() { Value = "Black", Order = 0, VocabularyValueDetail = new AttributeVocabularyValue() { Content = new AttributeVocabularyValueLocalizedContent() { LocaleCode = "en-US", StringValue = "Black" }, Value = "Black", ValueSequence = 10 } }); productTypeOptionColor.VocabularyValues.Add(new AttributeVocabularyValueInProductType() { Value = "Brown", Order = 0, VocabularyValueDetail = new AttributeVocabularyValue() { Content = new AttributeVocabularyValueLocalizedContent() { LocaleCode = "en-US", StringValue = "Brown" }, Value = "Brown", ValueSequence = 11 } }); existingProductType.Options.Add(productTypeOptionColor); var newProductType = productTypeHandler.UpdateProductType(_apiContext.TenantId, _apiContext.SiteId, _apiContext.MasterCatalogId, existingProductType).Result; } }