List Deparments programatically - Ecommerce - Ecommerce - Progress Community

List Deparments programatically


List Deparments programatically

  • List Deparments programatically
  • I need to build my own navigation widget for the Departments of a store.

    But I can't find any documentation on how to grab and list Departments. Only to simple crud operations. I suppose this is done the same way as other taxons, but I can't find any examples of that as well.


  • You can use the TaxonomyManager to get all of the Departments.

    Something like:

    var departmentsTaxonomy = TaxonomyManager.GetManager().GetTaxonomy(TaxonomyManager.DepartmentsTaxonomyId);

    Will get you the departments taxonomy. After that you can access each Department by iterating over the "Taxa" property of "departmentsTaxonomy".

  • Thanks Thomas,

    I ended up using this code, witch works great:
        TaxonomyManager tm = TaxonomyManager.GetManager();
        var depatments = tm.GetTaxonomies<HierarchicalTaxonomy>().Where(t => t.Name == "Departments").SingleOrDefault();
       var subGroup = depatments.Taxa.Where(t => t.Title == itm.ToolTip).SingleOrDefault();
            if(subGroup!= null)
                foreach (HierarchicalTaxon t in subGroup.Taxonomy.Taxa.Where(a => a.Parent == subGroup))
                    RadMenuItem newItm = new RadMenuItem(t.Title);
                    newItm.CssClass = itm.ToolTip + "MenuItem";

    BUT: How can I get the subgroup Taxas sorted?

    Thanks for any input!

  • Hi Ole,

    You can cast your first result to HierarchicalTaxon and then simply use the Subtaxa property of HierarchicalTaxon and use the OrderBy method of LINQ:

    var subGroup = depatments.Taxa.Where(t => t.Title == "Title").SingleOrDefault() as HierarchicalTaxon;
    foreach (HierarchicalTaxon t in subGroup.Subtaxa.OrderBy(t => t.Title))

    Lubomir Velkov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items