Copied to clipboard

Flag this post as spam?

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


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Dennis Aaen 4457 posts 17970 karma points admin hq c-trib
    Jul 10, 2014 @ 09:42
    Dennis Aaen
    0

    Get properties of item.

    Hi

    Maybe this is a simple question, but how can I pull out data from a custom property I just made on my default category definition.

    The name of the new property I have made is categoryAreaaHeading.

    I have tried something like this:

    @category.categoryAreaaHeading
    @category.categoryAreaaHeading()
    

    Both without any luck.

    My code looks like this:

    @using UCommerce.EntitiesV2
    @using UCommerce.Extensions
    @using UCommerce.Runtime
    @using umbraco.MacroEngines
    @{
        Category category = SiteContext.Current.CatalogContext.CurrentCategory;
    }
    
    @category.categoryAreaaHeading
    

    If somebody can help, the help will be much appreciated.

    /Dennis

  • Tim 168 posts 371 karma points
    Jul 10, 2014 @ 13:56
    Tim
    100

    Hi Dennis,

    There should be two ways you can access the property:

    var category = SiteContext.Current.CatalogContext.CurrentCategory;
    
    // Access the property by key
    var property = category["CategoryAreaaHeading"];
    if (property != null)
    {
        var propertyValue = property.GetValue();
        @propertyValue;
    }
    
    // Access the property using the method
    var property = category.GetProperty("CategoryAreaaHeading");
    if (property != null)
    {
        var propertyValue = property.GetValue();
        @propertyValue;
    }
    

    BTW was "categoryAreaaHeading" meant to be "categoryAreaHeading"?

    Let me know how you get on.

    Tim

  • Dennis Aaen 4457 posts 17970 karma points admin hq c-trib
    Jul 10, 2014 @ 14:32
    Dennis Aaen
    0

    Hi Tim,

    Thanks for your help,

    It works, like a charm.

    /Dennis

  • 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.

Please Sign in or register to post replies