Copied to clipboard

Flag this post as spam?

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


  • Biagio Paruolo 1594 posts 1825 karma points c-trib
    Aug 18, 2016 @ 14:26
    Biagio Paruolo
    0

    Solution if you need to access to a Merchello collection from a page.

    Hi,

    I find this solution if you need to access to a product collection. From an Umbraco page:

     @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @using Archetype.Models;
    @using Archetype.Extensions;
    @using Merchello.Core.Models
    @using Merchello.FastTrack.Ui
    @using Merchello.Web
    
    @{
        Layout = "Layout.cshtml";
    
        var storeRoot = ExampleUiHelper.Content.GetStoreRoot();
        var mHelper = new MerchelloHelper();
    
    
        var inevidenza = mHelper.TypedProductContentFromCollection(Guid.Parse("a6d13a30-2e2b-4d30-83b7-1dfaacc1997f")).ToList();
    
    }
    

    Then you can list products:

    @foreach (var item in inevidenza)
                    {
    
                        <div class="nf-col-padding">
                            <div class="item-box">
    
                                <div class="shop-item">
                                    <div class="item-img">
    
                                        @if (item.HasValue("image"))
                                        {
                                            var mediaId = item.GetPropertyValue<string>("image");
                                            var image = Umbraco.TypedMedia(mediaId);
                                            <img class="img-responsive" src="@image.GetCropUrl(200, 200)" alt="@item.Name">
    
                                        }
    
                                    </div>
    
                                </div>
    
                                <div class="shop-item-info">
                                    <a href="@item.Url">
                                        <h6 class="shop-item-name">@item.Name</h6>
                                    </a>
    
                                </div>
    
                            </div>
    
                        </div>
    
                    }
    

    Bye

Please Sign in or register to post replies

Write your reply to:

Draft