Well I really wanted to show the "Item Count" next to my categories but it was sooo slow.
So here is my update. Hope it helps:
Description
I am caching the item count only. The "Clear Cache" in the admin section will clear this out if you ever add a new category or new item to increase the count
Update
Open CategoryNavigation.ascx.cs
Go to the GetNumberOfProducts method and change it to this
protected int GetNumberOfProducts(Category category, bool includeSubCategories)
{
int numberOfProducts = 0;
if (Cache.Get("numberOfProducts" + category.CategoryId) == null)
{
var products = this.ProductService.GetAllProducts(category.CategoryId,
0, 0, null, null, null, string.Empty, false, 1, 0,
null, ProductSortingEnum.Position, out numberOfProducts);
if (includeSubCategories)
{
var subCategories = this.CategoryService.GetAllCategoriesByParentCategoryId(category.CategoryId);
foreach (var subCategory in subCategories)
{
int tmp1 = GetNumberOfProducts(subCategory, includeSubCategories);
numberOfProducts += tmp1;
}
}
Cache.Insert("numberOfProducts" + category.CategoryId, numberOfProducts);
}
else
{
numberOfProducts = (int)Cache.Get("numberOfProducts" + category.CategoryId);
}
return numberOfProducts;
}
Compile and go
End of How To
Hope this helps some people! Let me know!
Cody of CoJoBaby.com