Copied to clipboard

Flag this post as spam?

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


  • Tony 105 posts 163 karma points
    Aug 16, 2016 @ 22:19
    Tony
    0

    Product Search

    Im running a query

    var productAll = merchello.Query.Product.Search(1, 50).Items.ToList();
    
    var productAvailable = productAll.Select(x => ((ProductDisplay)x).AsProductContent()).ToList();
    

    In productAll I get the first 50 products. Great.

    When I then cast them to product items, all the products which are not 'Available' get removed and a null value is left in its place?

    Why are these removed, surely if I want just available products I can just filter where the Available is set to true?

    And if you are removing them, shoudlnt you do this in teh first call so that my productAll woudl contain 50 'valid' products?

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Aug 16, 2016 @ 22:43
    Rusty Swayne
    0

    It's actually the AsProductContent() extension that is removing them. I've been trying to come up with a solution to this situation but am at a bit of a loss.

    The real issue is that the products that are null do not have a content type associated with them (or they are set not to render). If they don't have a content type, they can't be IProductContent ...

    The Search method you are calling returns ProductDisplay objects (which are not IPublishedContent).

    Would love a suggestion here.

  • Tony 105 posts 163 karma points
    Aug 16, 2016 @ 23:11
    Tony
    0

    It only seems to be the Available checkbox which is causing this. If I check a product as available, it appears in the results, all the results that are getting stripped out have content types and are available to render.

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Aug 16, 2016 @ 23:16
    Rusty Swayne
    0

    Thanks Tony - that does sound like an issue that should be looked into. Can you add it to the issue tracker http://issues.merchello.com and I'll take a look.

Please Sign in or register to post replies

Write your reply to:

Draft