예제 #1
0
        private void BuildMediaSection(TemplateBuilder builder, int sortOrder)
        {
            var resourceManager = ObjectFactory.Instance.Resolve <IResourceManager>();
            var userService     = ObjectFactory.Instance.Resolve <IUserService>();

            builder.CreateSection(resourceManager.GetLocalizedText(userService.GetCurrentUserCulture(), "Tabs", "Media"), FieldIds.Category.SectionMediaId, sortOrder);

            builder.CreateImageField(FieldIds.Category.ImageFieldId, "Image", 0);
        }
        private void BuildCommonSection(TemplateBuilder builder, int sortOrder)
        {
            var resourceManager = ObjectFactory.Instance.Resolve <IResourceManager>();
            var userService     = ObjectFactory.Instance.Resolve <IUserService>();

            builder.CreateSection(resourceManager.GetLocalizedText(userService.GetCurrentUserCulture(), "Tabs", "Common"), FieldIds.Catalog.SectionCommonId, sortOrder);

            builder.CreateTextField(FieldIds.Catalog.NameFieldId, "Name", 10);
            builder.CreateTextField(FieldIds.Catalog.CatalogIdFieldId, "Catalog id", 20);
            builder.CreateTextField(FieldIds.Catalog.DisplayNameFieldId, "Display name", 30);
            builder.CreateDropdownList(FieldIds.Catalog.DefaultPriceGroupId, "Default price group", 40, FieldIds.SystemContent.PriceGroupsFolderId);
            builder.CreateCheckBoxField(FieldIds.Catalog.ShowPricesWithVatId, "Show prices with VAT", 50);
        }
        private void BuildAllowedPriceGroupsSection(TemplateBuilder builder, int sortOrder)
        {
            builder.CreateSection("Allowed Price Groups", FieldIds.Catalog.SectionAllowedPriceGroupsId, sortOrder);

            var priceGroups = PriceGroup.Find(x => !x.Deleted).OrderBy(x => x.Name).ToList();

            _priceGroupIdToFieldIdMap.Clear();

            int priceGroupSortOrder = 10;

            foreach (var priceGroup in priceGroups)
            {
                ID priceGroupFieldId = priceGroup.GetOrCreateAllowedPriceGroupFieldId(FieldIds.Catalog.SectionAllowedPriceGroupsId);
                _priceGroupIdToFieldIdMap[priceGroup.PriceGroupId] = priceGroupFieldId;
                AddPriceGroupSpecificField(builder, priceGroup, priceGroupSortOrder, priceGroupFieldId);
                priceGroupSortOrder += 10;
            }
        }
예제 #4
0
        private void BuildCommonSection(TemplateBuilder builder, int sortOrder)
        {
            var resourceManager = ObjectFactory.Instance.Resolve <IResourceManager>();
            var userService     = ObjectFactory.Instance.Resolve <IUserService>();

            builder.CreateSection(resourceManager.GetLocalizedText(userService.GetCurrentUserCulture(), "Tabs", "Common"), FieldIds.Category.SectionCommonId, sortOrder);

            builder.CreateTextField(FieldIds.Category.NameFieldId, "Name", 1);
            builder.CreateTextField(FieldIds.Category.CategoryIdFieldId, "Category id", 2);
            builder.CreateTextField(FieldIds.Category.ParentCatalogIdFieldId, "Product catalog id", 3);
            builder.CreateCheckBoxField(FieldIds.Category.DisplayOnSiteFieldId, "Display on site", 6);
            builder.CreateTextField(FieldIds.Category.DisplayNameFieldId, "Display name", 7);
            builder.CreateRichTextEditorField(FieldIds.Category.DescriptionFieldId, "Description", 8);

            // Avoid creating products field on categories if the product data is not included.
            var includeProductData = _dataProviderSettings.IncludeProductData;

            if (includeProductData)
            {
                BuildListOfProductsField(builder, 10);
            }
        }
예제 #5
0
        public TemplateItem BuildCategoryTemplateFromDefinition(IDefinition definition)
        {
            var builder     = new TemplateBuilder();
            var userService = ObjectFactory.Instance.Resolve <IUserService>();

            var cultureInfo     = userService.GetCurrentUserCulture();
            var resourceManager = ObjectFactory.Instance.Resolve <IResourceManager>();
            var sectionName     = resourceManager.GetLocalizedText(cultureInfo, "Tabs", "DynamicFields");

            var specificDefinition = definition as Definition;

            ID templateId = definition.SitecoreTemplateId();

            builder.CreateTemplate(definition.Name, templateId, definition.Name, definition.GetBaseTemplateIds());
            _definitionIdToTemplateIdMap[specificDefinition.DefinitionId] = templateId;

            var combinedFields = new List <IDefinitionField>();

            combinedFields.AddRange(((Definition)definition).DefinitionFields);

            if (combinedFields.Any())
            {
                ID sectionId = definition.SitecoreDynamicFieldsSectionId(templateId);
                builder.CreateSection(sectionName, sectionId, 150);

                int sortOrder = 10;
                foreach (var definitionField in combinedFields.Where(x => x.RenderInEditor))
                {
                    CreateDynamicItemField(builder, definitionField, sortOrder, sectionId);
                    sortOrder += 10;
                }
            }

            var template = builder.Build();

            template.AddToFieldList(FieldIDs.Icon, SitecoreConstants.UCommerceIconFolder + "/ui/map.png");

            return(template);
        }