November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
I think the first option is the way to go. C# does not allow multiple inheritance anyway.
You can extract as many shared properties as possible, put them in an abstract class - inherited from ProductContent or VariationContent, then inherit from that class.
One other option is to define a IContact interface. You will still need to implement the properties in your catalog content types, but your business code can now only care about the interface, and forget about the actual type.
Regards.
/Q
Q,
To clarify, my second diagram doesn't show mutliple inheritance - it shows my products composed of a Contact, something like:
public class Contact()
{
public string Firstname { get; }
public string Surname { get; }
}
public class ProductTypeA: VariationContent
{
public string Description { get; }
public Contact Who { get; }
}
I guess you'd need a custom meta type or something for Commerce to be able to undertsand how to render the Contact type?
Regards
If different types of products share common fields, whats the best way to implement this for Commerce?
For example, I have two products that both require Contact Firstname and Contact Surname fields.
Simple inheritance - with product types inheriting from a class containing the shared fields which in turn inherits from EPiServer.Commerce.Catalog.ContentTypes.ProductContent?
Or can a custom type be defined to encapsulate a Contact, and our product types have a public property of that type?