Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Lesley 107 posts 349 karma points
    Jan 07, 2016 @ 03:41
    Lesley
    0

    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.

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Jan 07, 2016 @ 17:02
    Rusty Swayne
    1

    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 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");
    
  • Lesley 107 posts 349 karma points
    Jan 07, 2016 @ 20:19
    Lesley
    0

    Got it working, but found I had to use

    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");
    

    returns null.

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Jan 07, 2016 @ 21:14
    Rusty Swayne
    0

    @Lesley,

    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.

  • OP10 3 posts 175 karma points
    Aug 14, 2018 @ 13:16
    OP10
    0

    Hi @rusty

    I also have some problems to get the extended content values.

    var products = Merchello.Query.Product.TypedProductContentSearch(1, int.MaxValue);
    

    When I look in one of the returned products there are no detachedcontent values.

    Same result here:

    var content = Merchello.TypedProductContent(Model.Key);
    

    I get the values when i do this:

    var product = Merchello.Query.Product.GetByKey(Model.Key);
    
Please Sign in or register to post replies

Write your reply to:

Draft