Developer forum

Forum » Development » ProductFieldTypeProvider

ProductFieldTypeProvider

Aki Ruuskanen
Aki Ruuskanen
Reply

Hi,

I'm trying to get a ProductFieldTypeProvider to work. I have started with the class below and thought that it should show up in the list field types. But it don't. I need to create a product field type where I can select UserGroups. 

Are there any basic exmaples of a ProductFieldTypeProvider somewhere perhaps?

namespace Softgear.Industrilas.Data.Provider
{
    [AddInName("Mindflower.UserGroupSelectProvider")]
    [AddInLabel("User Group Selector")]
    [AddInActive(true)]
    [Serializable]
    public class UserGroupSelectProvider : ProductFieldTypeProvider, IDropDownOptions
    {
        private Lazy<Dictionary<string, string>> _options;

        public UserGroupSelectProvider()
        {
            _options = new Lazy<Dictionary<string, string>>();
        }

        public override object GetValue(object value, string languageId, Dictionary<string, string> settings)
        {
            return "Testing usergroups";
        }

        public override string GetAppenderInfo(string languageId, string settings)
        {
            return GetAppenderInfo(languageId, GetParameterValues(settings));
        }

        public override string GetAppenderInfo(string languageId, Dictionary<string, string> settings)
        {
            return "AppenderInfo";
        }

        protected override void Render(TextWriter writer, string id, bool enabled, string value, bool hasError, string text, string title)
        {
            throw new NotImplementedException();
        }

        [AddInParameter("Usergroups")]
        [AddInParameterEditor(typeof(UserGroupParameterEditor), "multiple=false;")]
        [AddInParameterGroup("Source")]
        public string[] Usergroups { get; set; }

        public Hashtable GetOptions(string dropdownName)
        {
            // Get Hashtable
            Hashtable options = new Hashtable();

            foreach (var key in _options.Value.Keys)
            {
                options.Add(key, _options.Value[key]);
            }

            // Return the hashtable
            return options;
        }

    }
}

Replies

 
Morten Bengtson Dynamicweb Employee
Morten Bengtson
Reply
This post has been marked as an answer

Hi Aki,

Did you create a new field type and map it to your field type provider?

Settings > Ecommerce > Product catalog > Field types

https://doc.dynamicweb.com/documentation-9/platform/platform-tools/field-types#10591 

Votes for this answer: 1
 
Aki Ruuskanen
Aki Ruuskanen
Reply

Aaah. Thats it. I thought that it would appear in the list when I deploy the code. 

Thanks!

Regards / Aki

 
Aki Ruuskanen
Aki Ruuskanen
Reply

Hi,

When I try to map it I get an error sayin "UserSelectorSettings is not defined".

What am I missig?

Regards / Aki

 

You must be logged in to post in the forum