public IEnumerable <ISitecoreItem> BuildTemplates() { var templateData = new List <ISitecoreItem>(); var builder = new TemplateBuilder(); builder.CreateTemplate("ProductCategoryTemplate", FieldIds.Category.ProductCategoryTemplateId, "Product Category Template", TemplateIDs.StandardTemplate); BuildCommonSection(builder, 100); BuildMediaSection(builder, 200); var template = builder.Build(); template.AddToFieldList(FieldIDs.Icon, SitecoreConstants.UCommerceIconFolder + "/ui/map.png"); template.AddToFieldList(FieldIDs.Revision, Guid.NewGuid().ToString()); templateData.Add(template); var categoryDefinitionType = DefinitionType.Get(1); var repository = ObjectFactory.Instance.Resolve <IRepository <Definition> >(); var definitions = repository.Select(x => x.DefinitionType == categoryDefinitionType).ToList(); foreach (var definition in definitions) { var definitionTemplate = _dynamicCategoryTemplate.BuildCategoryTemplateFromDefinition(definition); definitionTemplate.SetRevision(definition.Guid.Derived(definition.ModifiedOn)); templateData.Add(definitionTemplate); } return(templateData); }
public IEnumerable <ISitecoreItem> BuildTemplates() { var templateData = new List <ISitecoreItem>(); var builder = new TemplateBuilder(); builder.CreateTemplate("uCommerce stores Template", FieldIds.Common.UCommerceStoresTemplateId, "uCommerce stores Template", TemplateIDs.StandardTemplate); var template = builder.Build(); template.AddToFieldList(FieldIDs.Icon, SitecoreConstants.UCommerceIconFolder + "/ui/map.png"); template.SetRevision(_revision); templateData.Add(template); return(templateData); }
public IEnumerable <ISitecoreItem> BuildTemplates() { var templateData = new List <ISitecoreItem>(); var builder = new TemplateBuilder(); builder.CreateTemplate("ProductCatalogTemplate", FieldIds.Catalog.ProductCatalogTemplateId, "Product Catalog Template", TemplateIDs.StandardTemplate); BuildCommonSection(builder, 10); BuildAllowedPriceGroupsSection(builder, 20); var template = builder.Build(); template.AddToFieldList(FieldIDs.Icon, SitecoreConstants.UCommerceIconFolder + "/ui/map.png"); template.SetRevision(Guid.NewGuid()); templateData.Add(template); return(templateData); }
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); }