public ActionResult Configure() { //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var googleAnalyticsSettings = _settingService.LoadSetting<GoogleAnalyticsSettings>(storeScope); var model = new ConfigurationModel(); model.GoogleId = googleAnalyticsSettings.GoogleId; model.TrackingScript = googleAnalyticsSettings.TrackingScript; model.EcommerceScript = googleAnalyticsSettings.EcommerceScript; model.EcommerceDetailScript = googleAnalyticsSettings.EcommerceDetailScript; model.ZoneId = googleAnalyticsSettings.WidgetZone; model.AvailableZones.Add(new SelectListItem() { Text = "<head> HTML tag", Value = "head_html_tag"}); model.AvailableZones.Add(new SelectListItem() { Text = "Before <body> end HTML tag", Value = "body_end_html_tag_before" }); var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); storeDependingSettingHelper.GetOverrideKeys(googleAnalyticsSettings, model, storeScope, _settingService); return View(model); }
public ActionResult Configure(ConfigurationModel model, FormCollection form) { ModelState.Clear(); //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var googleAnalyticsSettings = _settingService.LoadSetting<GoogleAnalyticsSettings>(storeScope); googleAnalyticsSettings.GoogleId = model.GoogleId; googleAnalyticsSettings.TrackingScript = model.TrackingScript; googleAnalyticsSettings.EcommerceScript = model.EcommerceScript; googleAnalyticsSettings.EcommerceDetailScript = model.EcommerceDetailScript; googleAnalyticsSettings.WidgetZone = model.ZoneId; _settingService.SaveSetting(googleAnalyticsSettings, x => x.WidgetZone, 0, false); var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData); storeDependingSettingHelper.UpdateSettings(googleAnalyticsSettings, form, storeScope, _settingService); //now clear settings cache _settingService.ClearCache(); return Configure(); }