예제 #1
0
 private void DeleteExampleProducts(CcSettings settings)
 {
     if (settings.SampleProducts != null)
     {
         foreach (var productId in settings.SampleProducts)
         {
             var product = _productService.GetProductById(productId);
             if (product != null)
             {
                 _productService.DeleteProduct(product);
             }
         }
     }
 }
예제 #2
0
        public override void Install()
        {
            var settings = new CcSettings
            {
                ServerHostUrl = @""
            };

            InstallAttributes(settings);
            _settingService.SaveSetting(settings);

            InstallLanguageResources();

            _ccDesignObjectContext.Install();
            base.Install();
        }
예제 #3
0
        private void UninstallAttributes(CcSettings settings)
        {
            // remove product attributes
            var attribute = _productAttributeService.GetProductAttributeById(settings.CcIdAttributeId);

            if (attribute != null)
            {
                _productAttributeService.DeleteProductAttribute(attribute);
            }

            // remove specification attributes
            var specificationAttribute =
                _specificationAttributeService.GetSpecificationAttributeById(settings.EditorConfigurationSpecificationAttributeId);

            if (specificationAttribute != null)
            {
                _specificationAttributeService.DeleteSpecificationAttribute(specificationAttribute);
            }

            specificationAttribute =
                _specificationAttributeService.GetSpecificationAttributeById(settings.EditorDefinitionSpecificationAttributeId);
            if (specificationAttribute != null)
            {
                _specificationAttributeService.DeleteSpecificationAttribute(specificationAttribute);
            }

            var specificationAttributeOption =
                _specificationAttributeService.GetSpecificationAttributeOptionById(settings.EditorDefinitionSpecificationOptionId);

            if (specificationAttributeOption != null)
            {
                _specificationAttributeService.DeleteSpecificationAttributeOption(specificationAttributeOption);
            }

            specificationAttributeOption =
                _specificationAttributeService.GetSpecificationAttributeOptionById(settings.EditorConfigurationSpecificationOptionId);
            if (specificationAttributeOption != null)
            {
                _specificationAttributeService.DeleteSpecificationAttributeOption(specificationAttributeOption);
            }
        }
예제 #4
0
        private void CreateExampleProducts(CcSettings settings)
        {
            var product = new Product
            {
                ProductType       = ProductType.SimpleProduct,
                ProductTemplateId = _productTemplateService.GetAllProductTemplates().First().Id,
                Name = "Business Card",
                VisibleIndividually  = true,
                ShowOnHomePage       = true,
                AllowCustomerReviews = true,
                Price        = 10,
                Published    = true,
                CreatedOnUtc = DateTime.Now,
                UpdatedOnUtc = DateTime.Now,
                AvailableStartDateTimeUtc = new DateTime(2015, 6, 1),
                OrderMaximumQuantity      = 100,
                OrderMinimumQuantity      = 1
            };

            _productService.InsertProduct(product);
            if (settings.SampleProducts == null)
            {
                settings.SampleProducts = new List <int>();
            }
            settings.SampleProducts.Add(product.Id);

            var productDefinition = new ProductSpecificationAttribute
            {
                AllowFiltering = true,
                AttributeType  = SpecificationAttributeType.CustomText,
                SpecificationAttributeOptionId = settings.EditorDefinitionSpecificationOptionId,
                CustomValue       = @"Default editor",
                DisplayOrder      = 0,
                ProductId         = product.Id,
                ShowOnProductPage = false
            };

            _specificationAttributeService.InsertProductSpecificationAttribute(productDefinition);

            var editorConfiguration = new ProductSpecificationAttribute
            {
                AllowFiltering = true,
                AttributeType  = SpecificationAttributeType.CustomText,
                SpecificationAttributeOptionId = settings.EditorConfigurationSpecificationOptionId,
                CustomValue       = @"Default config",
                DisplayOrder      = 0,
                ProductId         = product.Id,
                ShowOnProductPage = false
            };

            _specificationAttributeService.InsertProductSpecificationAttribute(editorConfiguration);

            #region product attribute mappings
            _productAttributeService.InsertProductAttributeMapping(new ProductAttributeMapping
            {
                AttributeControlType = AttributeControlType.TextBox,
                DefaultValue         = "",
                DisplayOrder         = 100,
                ProductId            = product.Id,
                ProductAttributeId   = settings.CcIdAttributeId
            });
            #endregion

            _urlRecordService.SaveSlug(product, product.ValidateSeName(product.Name, product.Name, true), 0);
        }
예제 #5
0
        private void InstallAttributes(CcSettings settings)
        {
            var attributes = _productAttributeService.GetAllProductAttributes();
            var specificationAttributes = _specificationAttributeService.GetSpecificationAttributes();

            var ccIdAttribute = attributes.FirstOrDefault(x => x.Name == "CcId");

            if (ccIdAttribute == null)
            {
                ccIdAttribute = new ProductAttribute()
                {
                    Name = "CcId"
                };
                _productAttributeService.InsertProductAttribute(ccIdAttribute);
            }

            var editorDefinitionSpecificationAttribute = specificationAttributes.FirstOrDefault(x => x.Name == "CC Editor");

            if (editorDefinitionSpecificationAttribute == null)
            {
                editorDefinitionSpecificationAttribute = new SpecificationAttribute
                {
                    Name         = "CC Editor",
                    DisplayOrder = 100
                };
                _specificationAttributeService.InsertSpecificationAttribute(editorDefinitionSpecificationAttribute);
            }

            var editorDefinitionSpecificationOption = editorDefinitionSpecificationAttribute.SpecificationAttributeOptions.FirstOrDefault(x => x.Name == "CC Editor");

            if (editorDefinitionSpecificationOption == null)
            {
                editorDefinitionSpecificationOption = new SpecificationAttributeOption
                {
                    DisplayOrder             = 0,
                    Name                     = "CC Editor",
                    SpecificationAttributeId = editorDefinitionSpecificationAttribute.Id
                };
                _specificationAttributeService.InsertSpecificationAttributeOption(editorDefinitionSpecificationOption);
            }

            var editorConfigurationSpecificationAttribute = specificationAttributes.FirstOrDefault(x => x.Name == "CC EditorConfig");

            if (editorConfigurationSpecificationAttribute == null)
            {
                editorConfigurationSpecificationAttribute = new SpecificationAttribute
                {
                    Name         = "CC EditorConfig",
                    DisplayOrder = 100
                };
                _specificationAttributeService.InsertSpecificationAttribute(editorConfigurationSpecificationAttribute);
            }

            var editorConfigurationSpecificationOption = editorDefinitionSpecificationAttribute.SpecificationAttributeOptions.FirstOrDefault(x => x.Name == "CC EditorConfig");

            if (editorConfigurationSpecificationOption == null)
            {
                editorConfigurationSpecificationOption = new SpecificationAttributeOption
                {
                    DisplayOrder             = 0,
                    Name                     = "CC EditorConfig",
                    SpecificationAttributeId = editorConfigurationSpecificationAttribute.Id
                };
                _specificationAttributeService.InsertSpecificationAttributeOption(editorConfigurationSpecificationOption);
            }

            // add to settings
            settings.CcIdAttributeId = ccIdAttribute.Id;
            settings.EditorDefinitionSpecificationAttributeId    = editorDefinitionSpecificationAttribute.Id;
            settings.EditorDefinitionSpecificationOptionId       = editorDefinitionSpecificationOption.Id;
            settings.EditorConfigurationSpecificationAttributeId = editorConfigurationSpecificationAttribute.Id;
            settings.EditorConfigurationSpecificationOptionId    = editorConfigurationSpecificationOption.Id;
        }