Created
July 17, 2013 12:47
-
-
Save sitefinitySDK/6020255 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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