We have added additional fields to the product extended content, how do we access this information in the Umbraco front end
i.e. we have nodes in Umbraco that are linked to Merchello products using the Merchello Product Selector. We want to display some of the Merchello product's extended data on the Umbraco page.
The property value converter for the Merchello Product Selector returns a ProductDisplay object.
You should be able to use the extension method AsProductContent() to return an object of type IProductContent which implements IPublishedContent and give you access to the properties in the standard Umbraco fashion.
So ...
var productDisplay = Model.Content.GetPropertyValue<ProductDisplay>("YOURPROPERTYNAME");
var productContent = productDisplay.AsProductContent();
var value = productContent.GetPropertyValue("SOME_CUSTOM_PROPERTY");
var productId = new Guid(Model.Content.GetProperty("merchelloProduct").DataValue.ToString());
var productContent = merchello.Query.Product.GetByKey(productId).AsProductContent();
For some reason
var productDisplay = Model.Content.GetPropertyValue<ProductDisplay>("merchelloProduct");
If your getting the product key from your property, you should be able to get the IProductContent directly using the MerchelloHelper
If you are doing this in razor, you could inherit from MerchelloTemplatePage or MerchelloViewPage{T} and then
var productId = new Guid(Model.Content.GetProperty("merchelloProduct").DataValue.ToString());
var productContent = Merchello.TypedProductContent(productId);
It basically does the same thing as what you are doing.
How to access product extended content?
We have added additional fields to the product extended content, how do we access this information in the Umbraco front end
i.e. we have nodes in Umbraco that are linked to Merchello products using the Merchello Product Selector. We want to display some of the Merchello product's extended data on the Umbraco page.
Hey Lesley,
The property value converter for the Merchello Product Selector returns a
ProductDisplay
object.You should be able to use the extension method
AsProductContent()
to return an object of typeIProductContent
which implementsIPublishedContent
and give you access to the properties in the standard Umbraco fashion.So ...
Got it working, but found I had to use
For some reason
returns null.
@Lesley,
If your getting the product key from your property, you should be able to get the
IProductContent
directly using theMerchelloHelper
If you are doing this in razor, you could inherit from
MerchelloTemplatePage
orMerchelloViewPage{T}
and thenIt basically does the same thing as what you are doing.
Hi @rusty
I also have some problems to get the extended content values.
When I look in one of the returned products there are no detachedcontent values.
Same result here:
I get the values when i do this:
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.