Copied to clipboard

Flag this post as spam?

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

  • Jason 92 posts 175 karma points
    Jul 11, 2015 @ 16:53

    Obtaining a product GUID


    I'm currently working through the examples within the documentation. A section of code doesn't appear to be correct. That, or I've made a mistake else where.

    My 'list-products' page is throwing a guid related error, due to this line:

     var result = contentProduct.GetPropertyValue("merchelloproduct").ToString();

    This is obviously returning a string, but it's not returning a string containing a guid. It's returning:


    As you'd expect, knock-off the 'ToString; and we get the {Merchello.Web.Models.ContentEditing.ProductDisplay} object.

    When debugging I can see that the object has a property (among others), called 'Key'. This is the Guid i'm trying to access..

    var theGuid = result.Key;

    The property isn't available to me it would seem.

    Any ideas?


  • Jason 92 posts 175 karma points
    Jul 11, 2015 @ 17:16


    var merchelloproductguid =  contentProduct.GetPropertyValue<ProductDisplay>("merchelloproduct").ToString();
  • Tessa 20 posts 72 karma points
    Nov 20, 2015 @ 22:14

    I had run across this issue, and just figured it out myself.

    The page I am using is inheriting the UmbracoTemplatePage.

    MerchelloHelper Merchello = new MerchelloHelper();
    Guid key = new Guid(CurrentPage.product.Key.ToString());
    var product = Merchello.Query.Product.GetByKey(key);
Please Sign in or register to post replies

Write your reply to: