Skip to content

Instantly share code, notes, and snippets.

@sitefinitySDK
Created July 17, 2013 12:47
Show Gist options
  • Save sitefinitySDK/6020255 to your computer and use it in GitHub Desktop.
Save sitefinitySDK/6020255 to your computer and use it in GitHub Desktop.
using System;
using System.Linq;
using Telerik.OpenAccess;
using Telerik.Sitefinity.Ecommerce.Catalog.Model;
using Telerik.Sitefinity.Model;
using Telerik.Sitefinity.Modules.Ecommerce.Catalog;
using Telerik.Sitefinity.Taxonomies;
using Telerik.Sitefinity.Taxonomies.Model;
namespace Telerik.Sitefinity.Documentation.CodeSnippets.SitefinityEssentials.Modules.Ecommerce.Products
{
public partial class ProductsCodeSnippets
{
public static IQueryable<Taxon> GetDepartmentsForProduct(Guid productId)
{
TaxonomyManager taxonomyManager = TaxonomyManager.GetManager();
CatalogManager ordersManager = CatalogManager.GetManager();
Product product = ordersManager.GetProduct(productId);
if (product == null)
{
return null; //Product does not exist.
}
var productDepartmentIds = product.GetValue<TrackedList<Guid>>("Department");
var productDepartments = taxonomyManager.GetTaxa<Taxon>().Where(t => productDepartmentIds.Contains(t.Id));
return productDepartments;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment