Try our conversational search powered by Generative AI!

Custom Product Type properties types and validation


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.


Jan 22, 2020 15:14
  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:
    public virtual string CustomProperty { get; set; }​

    More on BackingType here:

  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.
Jan 22, 2020 16:28

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.

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.