public void Get_Attributes() { var attributeHandler = new MozuDataConnector.Domain.Handlers.AttributeHandler(); var attributes = attributeHandler.GetAttributes(_apiContext.TenantId, _apiContext.SiteId, _apiContext.MasterCatalogId, 0, 20, null, null).Result; }
public void Update_SunGlass_Style_Attribute() { var attributeFQN = "tenant~sunglass-style"; var attributeValues = "Rectangle|Rimless|Butterfly|Oval|Wrap"; var filter = string.Format("attributeFQN eq '{0}'", attributeFQN); var attributeHandler = new MozuDataConnector.Domain.Handlers.AttributeHandler(); var attributes = attributeHandler.GetAttributes(_apiContext.TenantId, _apiContext.SiteId, _apiContext.MasterCatalogId, 0, 1, null, filter).Result; var existingAttribute = attributes.SingleOrDefault(a => a.AttributeFQN == attributeFQN); if (existingAttribute != null && existingAttribute.VocabularyValues != null) { foreach (var value in attributeValues.Split('|')) { existingAttribute.VocabularyValues.Add(new AttributeVocabularyValue() { Value = value, Content = new AttributeVocabularyValueLocalizedContent() { LocaleCode = "en-US", StringValue = value } }); } var newAttribute = attributeHandler.UpdateAttribute(_apiContext.TenantId, _apiContext.SiteId, _apiContext.MasterCatalogId, existingAttribute).Result; } }
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 Get_Popularity_Attribute() { var filter = "attributeFQN eq " + "'tenant~popularity'"; var attributeHandler = new MozuDataConnector.Domain.Handlers.AttributeHandler(); var attributes = attributeHandler.GetAttributes(_apiContext.TenantId, _apiContext.SiteId, _apiContext.MasterCatalogId, 0, 20, null, filter).Result; }
public void Add_SunGlass_Protection_Attribute() { var attributeFQN = "tenant~sunglass-protection"; var filter = string.Format("attributeFQN eq '{0}'", attributeFQN); var attributeHandler = new MozuDataConnector.Domain.Handlers.AttributeHandler(); var attributes = attributeHandler.GetAttributes(_apiContext.TenantId, _apiContext.SiteId, _apiContext.MasterCatalogId, 0, 1, null, filter).Result; var existingAttribute = attributes.SingleOrDefault(a => a.AttributeFQN == attributeFQN); if (existingAttribute == null) { var attributeCode = attributeFQN.Replace("tenant~", string.Empty); var attribute = new Mozu.Api.Contracts.ProductAdmin.Attribute() { AdminName = attributeCode, AttributeFQN = attributeFQN, AttributeCode = attributeCode, Content = new AttributeLocalizedContent() { LocaleCode = "en-US", Name = attributeCode.Replace("-", " ") }, DataType = "String", InputType = "TextBox", IsExtra = false, IsOption = false, IsProperty = true, LocalizedContent = null, MasterCatalogId = _apiContext.MasterCatalogId, Namespace = "tenant", SearchSettings = new AttributeSearchSettings() { SearchableInAdmin = true, SearchableInStorefront = true, SearchDisplayValue = true }, ValueType = "AdminEntered", VocabularyValues = null }; var newAttribute = attributeHandler.AddAttribute(_apiContext.TenantId, _apiContext.SiteId, _apiContext.MasterCatalogId, attribute).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 Add_SunGlass_Style_Attribute() { var attributeFQN = "tenant~sunglass-style"; var filter = string.Format("attributeFQN eq '{0}'", attributeFQN); var attributeHandler = new MozuDataConnector.Domain.Handlers.AttributeHandler(); var attributes = attributeHandler.GetAttributes(_apiContext.TenantId, _apiContext.SiteId, _apiContext.MasterCatalogId, 0, 20, null, filter).Result; //add a using clause for System.Linq; var existingAttribute = attributes.SingleOrDefault(a => a.AttributeFQN == attributeFQN); if (existingAttribute == null) { var attributeCode = attributeFQN.Replace("tenant~", string.Empty); var attribute = new Mozu.Api.Contracts.ProductAdmin.Attribute() { AdminName = attributeCode, AttributeFQN = attributeFQN, AttributeCode = attributeCode, Content = new AttributeLocalizedContent() { LocaleCode = "en-US", Name = attributeCode.Replace("-", " ") }, DataType = "String", InputType = "List", IsExtra = false, IsOption = true, IsProperty = true, LocalizedContent = null, MasterCatalogId = _apiContext.MasterCatalogId, Namespace = "tenant", SearchSettings = new AttributeSearchSettings() { SearchableInAdmin = true, SearchableInStorefront = true, SearchDisplayValue = true }, ValueType = "Predefined", VocabularyValues = new System.Collections.Generic.List <AttributeVocabularyValue>() { new AttributeVocabularyValue() { Value = "Pilot", Content = new Mozu.Api.Contracts.ProductAdmin.AttributeVocabularyValueLocalizedContent() { LocaleCode = "en-US", StringValue = "Pilot" } } } }; var newAttribute = attributeHandler.AddAttribute(_apiContext.TenantId, _apiContext.SiteId, _apiContext.MasterCatalogId, attribute).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; } }