+1-888-365-2779
Try Now
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

4 posts, 0 answered
  1. Solomon Shaffer
    Solomon Shaffer 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 Solomon Shaffer
    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 Solomon Shaffer
    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