Copied to clipboard

Flag this post as spam?

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


  • Jurgen Van de Water 18 posts 68 karma points
    Dec 27, 2015 @ 11:47
    Jurgen Van de Water
    0

    How to get collections (categories)

    Hi,

    I have some collections in Merchello where I categorize my products.

    I want to achieve something like this:

    • Category 1 (5)
    • Category 2 (10)
    • Category 3 (6) ...

    I succeeded to make the collections and linked the products to the different collections, but now I want to access them in my front-end.

    How can I achieve that? I already checked merchelloHelper.Query.Products but there is no collections property available.

    I hope I don't have to make the full category structure in Umbraco, because I then have to do things twice.

    Is there an easy way to access all my collections in Merchello?

    Thanks for your help.

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Dec 28, 2015 @ 18:56
    Rusty Swayne
    0

    There is a data type (Merchello Product List View) which is intended to be added to your category content pages. The property value converter returns IEnumerable<IProductContent> for the collection. The value stored in the content is the Key (GUID) for the entity collection ...

    If you want to work with your product collections directly, you can either use the EntityCollectionService or merchelloHelper.Query.Product.GetFromCollection (overloads)

  • Jurgen Van de Water 18 posts 68 karma points
    Jan 11, 2016 @ 08:43
    Jurgen Van de Water
    0

    Hi,

    Sorry for the late response.

    I'm trying out IEnumerable

    I made a collection Motor in Merchello and then linked one product to that collection. I've created a product list view data type and selected to show only the Motor collection in that list view. But then I don't receive the Motor product.

    I've already did some debugging and when I look at the results of

    Model.Content.GetPropertyValue<IEnumerable<IProductContent>>("listView")
    

    I get 'The function evaluation requires all threads to run' and it skips the foreach I'm doing to read out the name of the product.

    What could be the problem here?

    Here is my full foreach code:

    @foreach(IProductContent item in Model.Content.GetPropertyValue<IEnumerable<IProductContent>>("listView"))
        {
            <span>@item.Name</span>
        }
    
  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Jan 11, 2016 @ 16:44
    Rusty Swayne
    0

    Can you confirm your product is set to render?

    In your content, for your listView property, look at the Render column - it should have a check mark:

    enter image description here

    If it is not checked, you need to check to make certain your product is "available for purchase".

    enter image description here

    If it is available, check the render tab on extended content to make sure the product has the "Allow this content to be rendered" check box checked.

    enter image description here

  • Jurgen Van de Water 18 posts 68 karma points
    Jan 13, 2016 @ 14:43
    Jurgen Van de Water
    0

    I've got it working for the collections. But on my root page of the shop I want to show all collections and products.

    When I do

    foreach (IProductContent productContent in Model.Content.GetPropertyValue<IEnumerable<IProductContent>>("listView"))
    

    on the root page, then the result is empty and I get an object refence not set to an instance of an object. When I go to a collection page, everything is fine.

    So selecting all collections for the list view is not returning anything on my root page, but when I go to a collection page the different products for that collection are shown.

    What could be the problem?

  • PierreD Savard 183 posts 290 karma points
    Aug 17, 2016 @ 19:26
    PierreD Savard
    0

    In the same idea. Do we have a way to rapidly found all categories belong to one product?

  • MIke Cole 3 posts 75 karma points
    Jan 09, 2018 @ 16:09
    MIke Cole
    0

    Hi, I need to access the collection that the product list view is pulling from in order to get filter groups, number of products in a collection, etc. Has anyone figured out how to get the collection key from the selected collection in the product list veiw?

  • Nick Hoang 51 posts 180 karma points
    Mar 27, 2018 @ 05:33
    Nick Hoang
    2

    Hi PierreD

    This is how I get product collections

    var merchelloHelper = new MerchelloHelper(); var collections = merchelloHelper.Collections.Product.GetAll().Where(c=>c.ParentKey == null && c.Name != "Featured Products").ToList();

    Hope it helps

    Cheers, Nick

Please Sign in or register to post replies

Write your reply to:

Draft