protected void SaveSettingsButton_Click(object sender, EventArgs e) { var store = new CommerceSiteMappingStore(); foreach (RepeaterItem item in CatalogRepeater.Items) { var catalogIdHiddenField = item.FindControl("CatalogIdHiddenField") as HiddenField; var productTemplateDropDownList = item.FindControl("ProductTemplateDropDownList") as DropDownList; var productListTemplateDropDownList = item.FindControl("ProductListTemplateDropDownList") as DropDownList; int catalogId; if (int.TryParse(catalogIdHiddenField.Value, out catalogId)) { var mapping = store.Find(catalogId); if (mapping == null) { mapping = new CommerceSiteMapping(); mapping.CatalogId = catalogId; } int productListPageTypeId; if (int.TryParse(productListTemplateDropDownList.SelectedValue, out productListPageTypeId)) { mapping.CatalogNodePageTypeId = productListPageTypeId; mapping.FallbackPageTypeId = productListPageTypeId; } int productPageTypeId; if (int.TryParse(productTemplateDropDownList.SelectedValue, out productPageTypeId)) { mapping.CatalogEntryPageTypeId = productPageTypeId; } store.Add(mapping); } } }
protected void CatalogRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e) { var item = e.Item.DataItem as CatalogDto.CatalogRow; if (item != null) { var productListPageTypeDropDownList = e.Item.FindControl("ProductListTemplateDropDownList") as DropDownList; var productPageTypeDropDownList = e.Item.FindControl("ProductTemplateDropDownList") as DropDownList; var store = new CommerceSiteMappingStore(); var mapping = store.Find(item.CatalogId); foreach (var pageType in EPiServer.DataAbstraction.PageType.List()) { productListPageTypeDropDownList.Items.Add(new ListItem(pageType.Name, pageType.ID.ToString())); productPageTypeDropDownList.Items.Add(new ListItem(pageType.Name, pageType.ID.ToString())); if (mapping != null) { if (pageType.ID == mapping.CatalogNodePageTypeId) { productListPageTypeDropDownList.SelectedIndex = productListPageTypeDropDownList.Items.Count - 1; } if (pageType.ID == mapping.CatalogEntryPageTypeId) { productPageTypeDropDownList.SelectedIndex = productPageTypeDropDownList.Items.Count - 1; } } } } }
internal override string GetPageType(string key) { /* Original var param = SplitKey(key); var nodeType = (NodeType)Enum.Parse(typeof(NodeType), param[CatalogNodeType]); switch (nodeType) { case NodeType.CatalogNode: return GetPageType(SettingFactory.Instance.Setting.ProductListPageType); case NodeType.CatalogEntry: return GetPageType(SettingFactory.Instance.Setting.ProductDetailPageType); default: return GetPageType(SettingFactory.Instance.Setting.ProductListPageType); } */ var store = new CommerceSiteMappingStore(); var dictionary = SplitKey(key); NodeType nodeType; int catalogId; CommerceSiteMapping mapping; if (int.TryParse(dictionary["CatalogId"], out catalogId) && (mapping = store.Find(catalogId)) != null) { ProductListPageTypeId = mapping.CatalogNodePageType.ID; ProductDetailPageTypeId = mapping.CatalogEntryPageType.ID; nodeType = (NodeType)Enum.Parse(typeof(NodeType), dictionary["NodeType"]); switch (nodeType) { case NodeType.CatalogEntry: return mapping.CatalogEntryPageType.Name; case NodeType.CatalogNode: return mapping.CatalogNodePageType.Name; } return mapping.FallbackPageType.Name; } //return base.GetPageType(key); var param = SplitKey(key); ProductListPageTypeId = SettingFactory.Instance.Setting.ProductListPageType; ProductDetailPageTypeId = SettingFactory.Instance.Setting.ProductDetailPageType; nodeType = (NodeType)Enum.Parse(typeof(NodeType), param[CatalogNodeType]); switch (nodeType) { case NodeType.CatalogNode: return GetPageType(SettingFactory.Instance.Setting.ProductListPageType); case NodeType.CatalogEntry: return GetPageType(SettingFactory.Instance.Setting.ProductDetailPageType); default: return GetPageType(SettingFactory.Instance.Setting.ProductListPageType); } }