Are you trying to extend the IProductContent to include typed properties?
Assuming you're new class implements IPublishedContent you could use Ditto .As("").
You could also create your own factory to build your model off of IProductContent or for something quick add extension methods off of IProductContent.
I'd have to look this up, but I'm guessing there is a way to unregister Merchello's PropertyValueConverter for the Product List View data type and write your own to map directly to your model ... would love to see the solution on this if you do it.
In Merchello 2.1.0 the Product List View PropertyValueConverter now returns a type of ProductContentListView which implements IEnumerable<IProductContent> (so there is no breaking change).
I've not used the most recent Ditto, but you used to be able to write custom value resolvers based off their base type. I've heard these are legacy and there is a more preferred easier way to do the same thing.
Ditto should return the ProductContentListView by default (since it's just using Merchello's PropertyValueConverter). In order to get a typed (your type) enumeration of products, you would need to do a Ditto .As("[MYTYPE"] on each of the products in the enumerable - which would be done in the custom converter.
Strongly typed extended properties
Hi all,
Is there any way to extend this code to a custom Product class where I have the extended product properties?
Thanks,
Pedro
Hey Pedro,
Are you trying to extend the IProductContent to include typed properties?
Assuming you're new class implements IPublishedContent you could use Ditto .As("").
You could also create your own factory to build your model off of IProductContent or for something quick add extension methods off of IProductContent.
I'd have to look this up, but I'm guessing there is a way to unregister Merchello's PropertyValueConverter for the Product List View data type and write your own to map directly to your model ... would love to see the solution on this if you do it.
Did you ever find solution to this?
I too am using Ditto and Merchello and would like to map my extended properties to my Ditto Model as some are using composites
Hey Ben,
In Merchello 2.1.0 the Product List View PropertyValueConverter now returns a type of
ProductContentListView
which implementsIEnumerable<IProductContent>
(so there is no breaking change).I've not used the most recent Ditto, but you used to be able to write custom value resolvers based off their base type. I've heard these are legacy and there is a more preferred easier way to do the same thing.
Ditto should return the
ProductContentListView
by default (since it's just using Merchello's PropertyValueConverter). In order to get a typed (your type) enumeration of products, you would need to do a Ditto .As("[MYTYPE"] on each of the products in the enumerable - which would be done in the custom converter.Hi Rusty
I managed to get it work by just using my Model (IProductContent) for product related properties and then done a Model.As
Ditto does indeed return the ProductContentListView.
Think thats the right way to go :)
Thanks
Ben
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.