Developer forum

Forum » Development » Custom Product field type - example

Custom Product field type - example

Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi,

 

Can someone point or get me a quick example of how to develop a custom product field type?

 

I need to develop 3 field types for a customer:

  • Dropdown with a search
    Similar to what we have in Repository queries, but for a dropdown in Ecommerce
     
  • Checkbox/Multiselect with a search
    Similar concept as previously but allowing multiple values to be selected
     
  • Selection Box field (attached)
    The same control we have for selecting fields in the field display group.
    There is a need to choose from a list of options (left side) and have them sorted specifically (on the right column)

 

This all stems from a ListBox

If anyone has any code I could use as a foundatation, would be appreciated it.

 

Best Regards,

Nuno Aguiar

AdvancedFieldType.gif

Replies

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nuno,

We just created almost exactly the same types of fields :)

I will send you a link to the code.

Adrian

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply
This post has been marked as an answer

Oh my... Christmas is coming early this year. Can't wait to get it :)

Votes for this answer: 1
 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nuno,

Actually, I have figured that the code may be useful to somebody else as well.

I have attached an archive with our code, everybody should feel free to use it anyway they like.

We have not managed to re-use the ListBox type of field (I have posted a few questions on the forum) but we have worked around the limitations.

The list box is limited anyway to 100 Options which kind of defeats the scope for searching.

A few findings of my own that I would have loved to know upfront:

1. Keep in mind that the display of the fields in Ecommerce and PIM is a bit different and you will have to test in both interfaces.

2. We could not find a way to get the value of the ProductID in the Field (for example to try and build a list of options based on the values of some other field of that product)
3. If you will use it for ProductCategory Fields, try to avoid using "_" in the system names as the display of the control may not work in both e-commerce and PIM,. The rules for identifying the ProductCategorySystem name and the Field System name are based on the "_" value on a generated string. If you won;t use "_", you won;t have any issues.

Happy coding!

Adrian

 

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Adrian,

 

I am not able to build this. I tried creating the sln, updating the nuget packages and then noticed that the SelectionBox has moved from Dynamicweb.Extensibility to Dynamicweb.Controls.Legacy.Controls. There are a few more things to chase to get it to work though.

 

I can also see that you have a lot of code in there, likely serving more than I was looking for, which is making it harder for me to wrap my head around this.

 

Do you (or anyone) happen to have a simpler version that I could use?

 

Nuno

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nuno,

This code was used for 9.8 development. It is true that some things may have changed moving forward to 9.9.

I will check with my coleague if we have updated the code already to 9.9.

I am not sure if it's easy to isolate each of these Field Types into separate projects, but I will ask.

Adrian

 

You must be logged in to post in the forum