More in this section
Forums / Developing with Sitefinity / Get ALL tags (Taxons) in a list from TaxonomyManager

Get ALL tags (Taxons) in a list from TaxonomyManager

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
4 posts, 0 answered
  1. Cadre Admin
    Cadre Admin avatar
    6 posts
    Registered:
    30 Jan 2014
    04 Jan 2015
    Link to this post

    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!

  2. Jonathan
    Jonathan avatar
    119 posts
    Registered:
    19 Dec 2012
    05 Jan 2015 in reply to Cadre Admin
    Link to this post

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

     

     

  3. Faheem
    Faheem avatar
    5 posts
    Registered:
    29 Jul 2015
    01 Aug 2015 in reply to Cadre Admin
    Link to this post

    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

     

     

     

  4. Faheem
    Faheem avatar
    5 posts
    Registered:
    29 Jul 2015
    01 Aug 2015
    Link to this post

    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 

     

4 posts, 0 answered