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
Hi there,
I have a pool of products. Each product has categories assigned (multi node tree picker).
How do I filter when loading a category page? My approach so far wich does not work:
var shop = Umbraco.Content(2724); var currentkategorie = Model.Id.ToString(); var allproducts = shop.Children<Product>().Where(x => x.IsVisible()).Where(x => x.Value<IEnumerable<IPublishedContent>>("kategorien").ToString().Contains(currentkategorie));
Hi Edgar,
Try this code:
var shop = Umbraco.Content(2724); var currentkategorie = Model.Id; var allproducts = shop.Children().Where(x => x.IsVisible()).Where(x => x.Value<IEnumerable<IPublishedContent>>("kategorien").Select(y => y.Id).Contains(currentkategorie));
You are trying to get products by Category.Id, but in multi-node tree picker value stores as List of Udi
Thanks,
Alex
Hi Alex,
thanks a lot for your answer.
I guess it would work.
But unfortunately I have products without a category assigned. Therefore I get an System.ArgumentNullException:
System.ArgumentNullException: "The value must not be NULL. Parameter name: source"
Is it possible to check for NULL within the query?
EDIT:
I have put an extra Where statement with HasValue in it:
.Where(z => z.HasValue("kategorien"))
Yes, of course, juse add a check - x.HasValue("kategorien")
var allproducts = shop.Children().Where(x => x.IsVisible()).Where(x => x.HasValue("kategorien") && x.Value<IEnumerable<IPublishedContent>>("kategorien").Select(y => y.Id).Contains(currentkategorie));
Now I get the following error:
System.FormatException: "String "[{"name":"LEHRMITTEL"" is not a valid udi."
LEHRMITTEL is one of my categories.
Stupid coincidence. Before I used the multinode-treepicker for my categories, I used a multi Url Picker wich was not the best idea...
Since I than changed the datatype I guess the value from the multi Url Picker is still stored in that field. That is probably causing the conflict.
Any ideas how I can delete this content?
I tried to select a category but the site is not responding when I'm trying to save.
Do I have do clear the false value directly in MS SQL db?
Yes, you are right, it stores old values, and that's why you are not able to retrieve the data.
So you have to resave products
Alex,
thank you very much for your help.
I really appreciate it!
Have a nice evening.
You are always welcome and have a nice evening too!!!
Edgar, does a multinode tree picker contain one and many categories for different products?
One product can be assigned to multiple categories:
But can as well be assigned only to one category.
Hope that answers your question.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Filter by Multinode Treepicker value
Hi there,
I have a pool of products. Each product has categories assigned (multi node tree picker).
How do I filter when loading a category page? My approach so far wich does not work:
Hi Edgar,
Try this code:
You are trying to get products by Category.Id, but in multi-node tree picker value stores as List of Udi
Thanks,
Alex
Hi Alex,
thanks a lot for your answer.
I guess it would work.
But unfortunately I have products without a category assigned. Therefore I get an System.ArgumentNullException:
Is it possible to check for NULL within the query?
EDIT:
I have put an extra Where statement with HasValue in it:
Yes, of course, juse add a check - x.HasValue("kategorien")
Now I get the following error:
LEHRMITTEL is one of my categories.
Stupid coincidence. Before I used the multinode-treepicker for my categories, I used a multi Url Picker wich was not the best idea...
Since I than changed the datatype I guess the value from the multi Url Picker is still stored in that field. That is probably causing the conflict.
Any ideas how I can delete this content?
I tried to select a category but the site is not responding when I'm trying to save.
Do I have do clear the false value directly in MS SQL db?
Yes, you are right, it stores old values, and that's why you are not able to retrieve the data.
So you have to resave products
Alex,
thank you very much for your help.
I really appreciate it!
Have a nice evening.
You are always welcome and have a nice evening too!!!
Edgar, does a multinode tree picker contain one and many categories for different products?
One product can be assigned to multiple categories:
But can as well be assigned only to one category.
Hope that answers your question.
is working on a reply...