Get ALL tags (Taxons) in a list from TaxonomyManager

Posted by Community Admin on 04-Aug-2018 06:24

Get ALL tags (Taxons) in a list from TaxonomyManager

All Replies

Posted by Community Admin on 04-Jan-2015 00:00

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!

Posted by Community Admin on 05-Jan-2015 00:00

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);

 

 

Posted by Community Admin on 01-Aug-2015 00:00

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

 

 

 

Posted by Community Admin on 01-Aug-2015 00:00

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 

 

This thread is closed