Get ALL tags (Taxons) in a list from TaxonomyManager
I am trying to get all of the tags that are created in the system in a list. I am doing some heavy lifting with a lot of objects that require I look up each tag and add it to a collection for each object. This would be more efficient if I did not have to call
foreach
(var tagForProduct
in
tagsForProduct)
product.Tags.Add(taxonomyManager.GetTaxon(tagForProduct).Name);
for each object. But rather get the tags with one call and then search in that list.
foreach
(var tagForProduct
in
tagsForProduct)
product.Tags.Add(allTags.FirstOrDefault(x => x.id == tagForProduct).Name);
Can this be done?
Thanks!
This will get a list All tags within the current instance of sitefinity.
TaxonomyManager manager = TaxonomyManager.GetManager();
IEnumerable<
string
> taxonomies = manager.GetTaxonomies<FlatTaxonomy>().Where(t => t.Name ==
"tags"
).FirstOrDefault().Taxa.Select(ta => ta.Name);
Hi Solomon,
How you are getting tagsForProduct ? or what is this product.tag ? i cant see any such method.
I need to get list of all TAGs associated with a product object and similarly fetch other products having same TAGs. I am trying to build a 'Related Products' (just like Amazon)
Can you please help.
thanks
I got below line of code how to fetch Tags list associated with a product Item.
IList<Guid> prodTags = prod.GetValue<TrackedList<Guid>>(
"Tags"
).Where(g => g.ToString() == tagGuid.ToString()).ToList();
and its working fine.
Thanks