Hi. I'm trying to make a new FieldEditor to select a product from eCommerce. I followed the guide and it works, so far, for selecting the product. I would like to extend the Fieldeditor though, making it possible to supply what eCom group id to select from in the Item configuration. How do i do this? Where do i add extra fields to fill out when setting up the item type?
This is the code:
[Dynamicweb.Content.Items.Annotations.EditorAttribute("eCom editor")] public class ecomItemFieldType : Editor { public override Type DataType { get { return typeof(string); } } public override void BeginEdit(EditorContext context) { if (context != null && context.Output != null) { var v = context.Value != null ? context.Value.ToString() : "hilo"; var EcomEmployees = Dynamicweb.eCommerce.Products.Group.GetGroupByID("GROUP188"); context.Output.WriteLine(string.Format("<select name=\"" + base.Key + "\">", System.Web.HttpUtility.HtmlAttributeEncode(v))); // Iterate all products. foreach(var Employee in EcomEmployees.Products) { // Check if current employee is infact the selected one. string Selected = ""; if( Employee.ID.ToString() == v) { Selected = " selected=\"selected\""; } context.Output.WriteLine(string.Format("<option value=\"" + Employee.ID.ToString() +"\" "+Selected+">" + Employee.Name.ToString() +"</option>")); } context.Output.WriteLine(string.Format("</select>")); } } public override object EndEdit() { return base.HttpContext.Request[base.Key]; } } }
Thanks in advance.
Jonas