Copied to clipboard

Flag this post as spam?

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


  • Simon 692 posts 1068 karma points
    Sep 02, 2016 @ 10:05
    Simon
    0

    Get All Merchello Products

    Hi guys,

    Can anyone guide me on how I can get all products of Merchello, because I want just a drop-down with products Names.

    Thank you in advance.

    Kind Regards

  • Simon Dingley 1470 posts 3427 karma points c-trib
    Sep 02, 2016 @ 10:16
    Simon Dingley
    0

    Hi Simon,

    Try something like the following:

    merchelloHelper.Query.Product.Search(1, 10000)
    

    Where 10,000 is higher than the total number of products. I don't believe there is currently a method to directly request all products but it would be a good idea to add this as a new feature on the issue tracker as I can see it might be useful.

    Cheers, Simon

  • Simon 692 posts 1068 karma points
    Sep 30, 2016 @ 19:48
    Simon
    0

    But with this the query execution will occur so it can be used to skip for pagination.

    Are there another way how I can get all products as SQL, as LINQ?

    Thank you

  • Simon 692 posts 1068 karma points
    Dec 13, 2016 @ 14:48
    Simon
    0

    Hi Simon

    Can I use the GetAll() from https://github.com/Merchello/Merchello/blob/v2.2.0/src/Merchello.Core/Services/ProductService.cs - Product Service?

    It returns IEnumberable. I think I can filter using the where clause and execute later on, right?

    Kind Regards

  • john blair 48 posts 219 karma points
    Mar 25, 2019 @ 19:11
    john blair
    0

    Hi,

    I too am trying to get a list of products. I've used the following code but get 0 products back. I have installed the fasttrack starter kit and the catalog page shows all the products ok. Am i missing something? I rebuilt the Merchello examine indexes via the umbraco back end but made no difference. THe following code is run in vs from the App_Code folder. I'm using latest merchello and umbraco 7.x

    I've just started looking into the merchello api - it looks like there are almost no code examples out there...and i find im wasting my time in reflector...is it just me?

            var merchello = new MerchelloHelper();
            var allProducts = merchello.Query.Product.Search(0, int.MaxValue).Items.ToList();
    

    Ideally I wanted to use the Serarch method with the search term ....but thought it would be easy to get a basic list of products....i guess not.

    UPDATE: My search line of code was wrong - the first page is 1 not 0 - the following worked for me.

    // Merchello search - limit search to that configured on the front end.
    var allProducts = merchello.Query.Product.Search(q, 1, Convert.ToInt32(maxSearchItems)).Items.ToList();
    
  • Thi Tar 11 posts 91 karma points
    Jul 31, 2017 @ 12:13
    Thi Tar
    0

    Hi Simon,

    Have you achieved to get all products of Merchello? Did you use GetAll()? Can I ask you how did you do to achieve this?

    Thanks in advance

Please Sign in or register to post replies

Write your reply to:

Draft