London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Custom Product Type properties types and validation

Vote:
 

Hi there.
Although I have some experience with CMS, I don't have much knowledge with commerce. And I was requested to create a custom Product Type for the project I'm working on.
The problems are:

  1. I was not able to create custom validation to some properties (i.e. Property X must be greater then property Y). My custom validation class is ignored, allowing the user to create the product even with the properties values being invalid. The built-in GreaterThanAttribute also didn't sort effect. Also tried to create a custom attribute, again, nothing.
  2. One of the custom properties must be a string, but it should have one specific value between some available strings, Like a SelectOne/SelectionFactory on CMS, but these are not available on commerce.
  3. The GroupName and Order values from the DIsplayAttribute seems to not be recognized for products(they are ignored), so I can't organize my custom properties.

So, does anyone can shed me some light on these topics? Is it possible to create custom validations to custom products? How can I create a dropdown for that string property? How can I organize my custom properties(on different tabs or even with an Order value)?

I appreciate any help.

Thanks.

#216054
Jan 22, 2020 15:14
Vote:
 
  1. Could you perhaps provide some code for this?
  2. There is a trick for that in commerce, to achieve what you are describing i think you want to do this:
    [EPiServer.DataAnnotations.BackingType(typeof(EPiServer.Commerce.SpecializedProperties.PropertyDictionarySingle))]
    public virtual string CustomProperty { get; set; }​

    More on BackingType here: https://world.episerver.com/documentation/developer-guides/commerce/catalogs/catalog-content/

  3. GroupName and Order for the Display attribute is the correct way to do it and it works fine for us. I can't say why they are ignored for you.
#216058
Jan 22, 2020 16:28
Vote:
 

Thanks for the response Erik. I really appreciate. I will take a look on the 2nd item. 
About the rest, I'll have to give up trying to send a response, as this shit site doesn't allow me to publish it for some stupid reason.

best regards.

#216062
Jan 22, 2020 17:42
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.