Hello, I want to Show the number of distinct products besides each category BUT not the Parent Category.
The count on the home page shows Bed (0) (Where there is no product in any of the sub categories of Beds)
Dining (10) (Where different sub categories have different counts) and so on. I have enabled the option to include the total in the main category. If this is disabled then the count shows (0) obviously because there is no product in the parent category, they are all in the sub categories.
I want only the Sub Categories to show the count and not the Root/Main Categories. So the home page should show Beds Dining Rugs Chairs etc. without (0) or any other count.
var query = _productRepository.Table.Where(p => p.Published && !p.Deleted && p.VisibleIndividually);
//apply store mapping constraints query = await _storeMappingService.ApplyStoreMapping(query, storeId);
//apply ACL constraints var customer = await _workContext.GetCurrentCustomerAsync(); var customerRoleIds = await _customerService.GetCustomerRoleIdsAsync(customer); query = await _aclService.ApplyAcl(query, customerRoleIds);
//category filtering if (categoryIds != null && categoryIds.Any()) { query = from p in query join pc in _productCategoryRepository.Table on p.Id equals pc.ProductId where categoryIds.Contains(pc.CategoryId) select p; }
var cacheKey = _staticCacheManager .PrepareKeyForDefaultCache(NopCatalogDefaults.CategoryProductsNumberCacheKey, customerRoleIds, storeId, categoryIds);
It does show the number of products BUT I do not want this on the Main/Root Category.
It either shows the total of all products in the Category and Sub Category i.e. Beds (50) OR it shows Beds (0) ------> This is when I exclude the sub category Total.
* change this setting catalogsettings.showcategoryproductnumberincludingsubcategories to true to include sub-category product count at the main category. from Admin -> Configurations -> Settings -> All settings (advanced)
* or add those condition here src\Presentation\Nop.Web\Views\Shared\Components\CategoryNavigation\Default.cshtml and here src\Presentation\Nop.Web\Views\Shared\Components\TopMenu\Default.cshtml to remove (0) beside category