/// <summary> /// Runs the processor. /// </summary> /// <param name="args">The arguments.</param> public override void Process(ConfigurationPipelineArgs args) { object container = Context.Entity.Resolve(args.ConfigurationItemType, null); if (!(container is IEntity)) { return; } Item item = args.CustomData["item"] as Item; if (item == null) { return; } LinkDatabase linkDatabase = Globals.LinkDatabase; ItemLink[] links = linkDatabase.GetReferrers(item); foreach (ItemLink link in links) { Item source = link.GetSourceItem(); if (source.Parent.TemplateID != new ID(Configuration.Settings.GetSetting("Ecommerce.Settings.SettingsRootTemplateId"))) { continue; } this.RegisterInstance(args, (IEntity)container, source); args.AbortPipeline(); break; } }
/// <summary> /// Runs the processor. /// </summary> /// <param name="args">The arguments.</param> public override void Process(ConfigurationPipelineArgs args) { object container = Context.Entity.Resolve(args.ConfigurationItemType, null); if (!(container is IEntity)) { return; } Item item = args.CustomData["item"] as Item; if (item == null) { return; } LinkDatabase linkDatabase = Globals.LinkDatabase; ItemLink[] links = linkDatabase.GetReferrers(item); foreach (ItemLink link in links) { Item source = link.GetSourceItem(); if (source.Parent.TemplateID != new ID(Configuration.Settings.GetSetting("Ecommerce.Settings.SettingsRootTemplateId"))) { continue; } this.RegisterInstance(args, (IEntity)container, source); args.AbortPipeline(); break; } }
/// <summary> /// Runs the processor. /// </summary> /// <param name="args">The arguments.</param> public override void Process([NotNull] ConfigurationPipelineArgs args) { Assert.ArgumentNotNull(args, "args"); object container = Context.Entity.Resolve(args.ConfigurationItemType); if (!(container is IEntity)) { return; } if (Sitecore.Context.Site == null) { return; } if (Sitecore.Context.Database == null) { return; } string settingsPartialPath = Sitecore.Context.Site.Properties[EcommerceSiteSettingsAttribute]; if (string.IsNullOrEmpty(settingsPartialPath)) { settingsPartialPath = EcommerceSiteSettingsDefaultValue; } string settingsFullPath = FileUtil.MakePath(Sitecore.Context.Site.StartPath, settingsPartialPath); Item settingsItemRoot = Sitecore.Context.Database.GetItem(settingsFullPath); if (settingsItemRoot == null) { return; } if (settingsItemRoot.Template.ID.ToString() != SettingsRootTemplateId && settingsItemRoot.Template.BaseTemplates.Where(x => x.ID.ToString() == SettingsRootTemplateId).FirstOrDefault() == null) { return; } IEntity entity = (IEntity)container; Item settingsItem = settingsItemRoot.Axes.SelectSingleItem(string.Format(".//*[@@name='{0}']", entity.Alias)); if (settingsItem != null) { this.RegisterInstance(args, (IEntity)container, settingsItem); } args.AbortPipeline(); }