Пример #1
0
        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;
            }
            ;
        }
Пример #2
0
        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;
            }
            ;
        }