Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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?
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.
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.
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.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted