/// <summary> /// Gets the category. /// </summary> /// <param name="categoryId">The category unique identifier.</param> /// <param name="storeAlias">The store alias.</param> /// <param name="currencyCode">The currency code.</param> /// <returns></returns> public static ICategory GetCategory(int categoryId = 0, string storeAlias = null, string currencyCode = null) { if (categoryId == 0) { var currentCat = UwebshopRequest.Current.Category; if (storeAlias == null && currencyCode == null || currentCat == null) { return((ICategory)currentCat); } categoryId = currentCat.Id; } return(CategoryAdaptor.Create(DomainHelper.GetCategoryById(categoryId, storeAlias, currencyCode))); }
private static void GetCategoriesFromCategory(ICollection <ICategory> categoryList, ICategory mainCategory) { foreach (var category in mainCategory.SubCategories.Where(category => categoryList.All(x => x.Id != category.Id))) { categoryList.Add(CategoryAdaptor.Create(category)); } if (!mainCategory.SubCategories.Any()) { return; } foreach (var subCategory in mainCategory.SubCategories) { GetCategoriesFromCategory(categoryList, subCategory); // todo: this can loop } }
public static IEnumerable <ICategory> GetCurrentCategoryPath() { return(UwebshopRequest.Current.CategoryPath.Select(c => CategoryAdaptor.Create(DomainHelper.GetCategoryById(c.Id)))); }