From 8b0c754c47df52089e0b13a8b85d7d34716f5f8f Mon Sep 17 00:00:00 2001 From: KrzysztofPajak Date: Sun, 9 Aug 2026 10:47:24 +0200 Subject: [PATCH] fix(catalog): make the store scope explicit on the category, brand and collection lists GetAllCategories, GetAllBrands and GetAllCollections all defaulted storeId to "", and AclService.Authorize returns true for an empty store. Omitting the argument was therefore not a compile error and silently turned tenant filtering off - which is exactly what had happened in the storefront search page: it listed collections from every store, while the category block ten lines above it passed request.Store.Id. storeId cannot simply move to the front of the parameter list. All three methods take string parameters before it, so reordering would still compile at positional call sites while quietly swapping the arguments' meaning - the very class of bug being fixed here. Instead every parameter up to and including storeId is now required, with the order untouched. The compiler then named all 27 call sites and no call could change meaning without failing to build. Twenty-six of them already passed the right scope and only became explicit. The twenty-seventh, GetSearchHandler, is the defect above and now passes the request's store. AclServiceTest and the new AclMappingExtensionTests pin the fail-open, so a future change to it has to be deliberate. The latter also records a difference nobody had written down: AclService.Authorize admits an entity shared with a second store, while AccessToEntityByStore refuses it. Co-Authored-By: Claude Opus 5 --- .../Services/Brands/BrandService.cs | 4 +- .../Services/Categories/CategoryService.cs | 4 +- .../Services/Collections/CollectionService.cs | 4 +- .../Catalog/Brands/IBrandService.cs | 4 +- .../Catalog/Categories/ICategoryService.cs | 2 +- .../Catalog/Collections/ICollectionService.cs | 4 +- .../Common/GetSitemapXMLCommandHandler.cs | 2 +- .../Services/Brands/BrandServiceTests.cs | 2 +- .../Categories/CategoryServiceDbTests.cs | 2 +- .../Services/Security/AclServiceTest.cs | 18 ++++++ .../Extensions/AclMappingExtensionTests.cs | 58 +++++++++++++++++++ .../Controllers/BrandController.cs | 2 +- .../Controllers/CategoryController.cs | 2 +- .../Controllers/CollectionController.cs | 2 +- .../Controllers/DiscountController.cs | 2 +- .../Controllers/SearchController.cs | 5 +- .../Services/CategoryViewModelService.cs | 1 + .../Services/CollectionViewModelService.cs | 3 +- .../Controllers/DiscountController.cs | 4 +- .../Handlers/Catalog/GetBrandAllHandler.cs | 2 +- .../Handlers/Catalog/GetCategoryAllHandler.cs | 2 +- .../Catalog/GetCategorySimpleHandler.cs | 4 +- .../Catalog/GetCollectionAllHandler.cs | 2 +- .../Catalog/GetCollectionNavigationHandler.cs | 2 +- .../Catalog/GetHomepageBrandsHandler.cs | 2 +- .../Catalog/GetHomepageCollectionsHandler.cs | 2 +- .../Handlers/Catalog/GetMenuHandler.cs | 4 +- .../Handlers/Catalog/GetSearchHandler.cs | 4 +- .../Handlers/Common/GetSitemapHandler.cs | 4 +- 29 files changed, 116 insertions(+), 37 deletions(-) create mode 100644 src/Tests/Grand.Web.Admin.Tests/Extensions/AclMappingExtensionTests.cs diff --git a/src/Business/Grand.Business.Catalog/Services/Brands/BrandService.cs b/src/Business/Grand.Business.Catalog/Services/Brands/BrandService.cs index 465b32556..7e12b8a4d 100644 --- a/src/Business/Grand.Business.Catalog/Services/Brands/BrandService.cs +++ b/src/Business/Grand.Business.Catalog/Services/Brands/BrandService.cs @@ -57,8 +57,8 @@ public BrandService(ICacheBase cacheBase, /// Page size /// A value that indicates if it should shows hidden records /// Brands - public virtual async Task> GetAllBrands(string brandName = "", - string storeId = "", + public virtual async Task> GetAllBrands(string brandName, + string storeId, int pageIndex = 0, int pageSize = int.MaxValue, bool showHidden = false) diff --git a/src/Business/Grand.Business.Catalog/Services/Categories/CategoryService.cs b/src/Business/Grand.Business.Catalog/Services/Categories/CategoryService.cs index 46cee17da..906ed4e53 100644 --- a/src/Business/Grand.Business.Catalog/Services/Categories/CategoryService.cs +++ b/src/Business/Grand.Business.Catalog/Services/Categories/CategoryService.cs @@ -74,8 +74,8 @@ public CategoryService(ICacheBase cacheBase, /// Page size /// A value that indicates if it should shows hidden records /// Categories - public virtual async Task> GetAllCategories(string parentId = null, string categoryName = "", - string storeId = "", + public virtual async Task> GetAllCategories(string parentId, string categoryName, + string storeId, int pageIndex = 0, int pageSize = int.MaxValue, bool showHidden = false) { var query = from c in _categoryRepository.Table diff --git a/src/Business/Grand.Business.Catalog/Services/Collections/CollectionService.cs b/src/Business/Grand.Business.Catalog/Services/Collections/CollectionService.cs index db6a655ee..0175e0f78 100644 --- a/src/Business/Grand.Business.Catalog/Services/Collections/CollectionService.cs +++ b/src/Business/Grand.Business.Catalog/Services/Collections/CollectionService.cs @@ -61,8 +61,8 @@ public CollectionService(ICacheBase cacheBase, /// Page size /// A value that indicates if it should shows hidden records /// Collections - public virtual async Task> GetAllCollections(string collectionName = "", - string storeId = "", + public virtual async Task> GetAllCollections(string collectionName, + string storeId, int pageIndex = 0, int pageSize = int.MaxValue, bool showHidden = false) diff --git a/src/Business/Grand.Business.Core/Interfaces/Catalog/Brands/IBrandService.cs b/src/Business/Grand.Business.Core/Interfaces/Catalog/Brands/IBrandService.cs index bd2e353ce..11e09608f 100644 --- a/src/Business/Grand.Business.Core/Interfaces/Catalog/Brands/IBrandService.cs +++ b/src/Business/Grand.Business.Core/Interfaces/Catalog/Brands/IBrandService.cs @@ -17,8 +17,8 @@ public interface IBrandService /// Page size /// A value that indicates if it should shows hidden records /// Brands - Task> GetAllBrands(string brandName = "", - string storeId = "", + Task> GetAllBrands(string brandName, + string storeId, int pageIndex = 0, int pageSize = int.MaxValue, bool showHidden = false); diff --git a/src/Business/Grand.Business.Core/Interfaces/Catalog/Categories/ICategoryService.cs b/src/Business/Grand.Business.Core/Interfaces/Catalog/Categories/ICategoryService.cs index a6ce034fc..5015edb1a 100644 --- a/src/Business/Grand.Business.Core/Interfaces/Catalog/Categories/ICategoryService.cs +++ b/src/Business/Grand.Business.Core/Interfaces/Catalog/Categories/ICategoryService.cs @@ -15,7 +15,7 @@ public interface ICategoryService /// Page size /// A value that indicates if it should shows hidden records /// Categories - Task> GetAllCategories(string parentId = null, string categoryName = "", string storeId = "", + Task> GetAllCategories(string parentId, string categoryName, string storeId, int pageIndex = 0, int pageSize = int.MaxValue, bool showHidden = false); /// diff --git a/src/Business/Grand.Business.Core/Interfaces/Catalog/Collections/ICollectionService.cs b/src/Business/Grand.Business.Core/Interfaces/Catalog/Collections/ICollectionService.cs index ecae8e334..fa1c18d63 100644 --- a/src/Business/Grand.Business.Core/Interfaces/Catalog/Collections/ICollectionService.cs +++ b/src/Business/Grand.Business.Core/Interfaces/Catalog/Collections/ICollectionService.cs @@ -17,8 +17,8 @@ public interface ICollectionService /// Page size /// A value that indicates if it should shows hidden records /// Collections - Task> GetAllCollections(string collectionName = "", - string storeId = "", + Task> GetAllCollections(string collectionName, + string storeId, int pageIndex = 0, int pageSize = int.MaxValue, bool showHidden = false); diff --git a/src/Business/Grand.Business.Messages/Commands/Handlers/Common/GetSitemapXMLCommandHandler.cs b/src/Business/Grand.Business.Messages/Commands/Handlers/Common/GetSitemapXMLCommandHandler.cs index 4b89039f8..ce42c9ecd 100644 --- a/src/Business/Grand.Business.Messages/Commands/Handlers/Common/GetSitemapXMLCommandHandler.cs +++ b/src/Business/Grand.Business.Messages/Commands/Handlers/Common/GetSitemapXMLCommandHandler.cs @@ -231,7 +231,7 @@ private async Task> GetCategoryUrls(string parentCategor private async Task> GetBrandUrls(Language language, Store store) { - var brands = await _brandService.GetAllBrands(storeId: store.Id); + var brands = await _brandService.GetAllBrands(brandName: "", storeId: store.Id); var brandUrls = new List(); var storeLocation = GetStoreLocation(); foreach (var brand in brands) diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Brands/BrandServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Brands/BrandServiceTests.cs index e49faab2e..a648d49e9 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/Brands/BrandServiceTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Brands/BrandServiceTests.cs @@ -47,7 +47,7 @@ public async Task GetAllBrandsTest() await _brandService.InsertBrand(new Brand { Published = true }); //Act - var brand = await _brandService.GetAllBrands(); + var brand = await _brandService.GetAllBrands(brandName: "", storeId: ""); //Assert Assert.HasCount(3, brand); diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryServiceDbTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryServiceDbTests.cs index bf8f0484a..03583a402 100644 --- a/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryServiceDbTests.cs +++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryServiceDbTests.cs @@ -106,7 +106,7 @@ public async Task GetAllCategories() { var allCategory = GetMockCategoryList(); allCategory.ToList().ForEach(x => _categoryService.InsertCategory(x).GetAwaiter().GetResult()); - var result = await _categoryService.GetAllCategories(); + var result = await _categoryService.GetAllCategories(parentId: null, categoryName: "", storeId: ""); Assert.HasCount(5, result); } diff --git a/src/Tests/Grand.Business.Common.Tests/Services/Security/AclServiceTest.cs b/src/Tests/Grand.Business.Common.Tests/Services/Security/AclServiceTest.cs index 6d48b43ec..b59b1ae94 100644 --- a/src/Tests/Grand.Business.Common.Tests/Services/Security/AclServiceTest.cs +++ b/src/Tests/Grand.Business.Common.Tests/Services/Security/AclServiceTest.cs @@ -42,4 +42,22 @@ public void Authorize_ReturnTrue() _accessControlConfig.IgnoreStoreLimitations = true; Assert.IsTrue(_aclService.Authorize(product, "id")); } + + /// + /// Pins the fail-open: an empty store grants access even to an entity that is limited to other + /// stores. Callers therefore carry the whole burden of supplying the store - which is why the + /// list services no longer default that argument away. + /// + [TestMethod] + public void Authorize_WithoutAStore_GrantsAccessToAnEntityLimitedToOtherStores() + { + var product = new Product { + LimitedToStores = true, + Stores = { "another-store" } + }; + + Assert.IsFalse(_aclService.Authorize(product, "this-store"), "the store is not among the entity's stores"); + Assert.IsTrue(_aclService.Authorize(product, ""), "fail-open: no store means no check"); + Assert.IsTrue(_aclService.Authorize(product, (string)null), "fail-open: no store means no check"); + } } \ No newline at end of file diff --git a/src/Tests/Grand.Web.Admin.Tests/Extensions/AclMappingExtensionTests.cs b/src/Tests/Grand.Web.Admin.Tests/Extensions/AclMappingExtensionTests.cs new file mode 100644 index 000000000..8f8d4c83f --- /dev/null +++ b/src/Tests/Grand.Web.Admin.Tests/Extensions/AclMappingExtensionTests.cs @@ -0,0 +1,58 @@ +using Grand.Domain.Catalog; +using Grand.Web.AdminShared.Extensions; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Assert = Microsoft.VisualStudio.TestTools.UnitTesting.Assert; + +namespace Grand.Web.Admin.Tests.Extensions; + +[TestClass] +public class AclMappingExtensionTests +{ + /// + /// Pins the fail-open: an empty store grants access even to an entity limited to another store. + /// + [TestMethod] + public void AccessToEntityByStore_WithoutAStore_GrantsAccessToAnEntityLimitedToOtherStores() + { + var product = new Product { + LimitedToStores = true, + Stores = { "another-store" } + }; + + Assert.IsFalse(product.AccessToEntityByStore("this-store")); + Assert.IsTrue(product.AccessToEntityByStore(""), "fail-open: no store means no check"); + } + + /// + /// This check is stricter than AclService.Authorize on the same-sounding question: an entity + /// shared with a second store is refused here, while AclService grants it. Anyone reaching for + /// "does this store own the entity" has to pick deliberately between the two. + /// + [TestMethod] + public void AccessToEntityByStore_RefusesAnEntitySharedWithASecondStore() + { + var product = new Product { + LimitedToStores = true, + Stores = { "this-store", "another-store" } + }; + + Assert.IsFalse(product.AccessToEntityByStore("this-store")); + } + + [TestMethod] + public void AccessToEntityByStore_AcceptsAnEntityOwnedByThatStoreAlone() + { + var product = new Product { + LimitedToStores = true, + Stores = { "this-store" } + }; + + Assert.IsTrue(product.AccessToEntityByStore("this-store")); + } + + [TestMethod] + public void AccessToEntityByStore_RefusesAMissingEntity() + { + Assert.IsFalse(((Product)null).AccessToEntityByStore("this-store")); + } +} diff --git a/src/Web/Grand.Web.Admin/Controllers/BrandController.cs b/src/Web/Grand.Web.Admin/Controllers/BrandController.cs index e0a1ad7eb..fb242820f 100644 --- a/src/Web/Grand.Web.Admin/Controllers/BrandController.cs +++ b/src/Web/Grand.Web.Admin/Controllers/BrandController.cs @@ -273,7 +273,7 @@ public async Task ExportXlsx([FromServices] IExportManager { try { - var bytes = await exportManager.Export(await _brandService.GetAllBrands(showHidden: true)); + var bytes = await exportManager.Export(await _brandService.GetAllBrands(brandName: "", storeId: "", showHidden: true)); return File(bytes, "text/xls", "brands.xlsx"); } catch (Exception exc) diff --git a/src/Web/Grand.Web.Admin/Controllers/CategoryController.cs b/src/Web/Grand.Web.Admin/Controllers/CategoryController.cs index 61cecf604..9b962438d 100644 --- a/src/Web/Grand.Web.Admin/Controllers/CategoryController.cs +++ b/src/Web/Grand.Web.Admin/Controllers/CategoryController.cs @@ -230,7 +230,7 @@ public async Task ExportXlsx([FromServices] IExportManager ExportXlsx([FromServices] IExportManager CategoryAddPopupList(DataSourceRequest command, DiscountModel.AddCategoryToDiscountModel model, [FromServices] ICategoryService categoryService) { - var categories = await categoryService.GetAllCategories(categoryName: model.SearchCategoryName, + var categories = await categoryService.GetAllCategories(parentId: null, categoryName: model.SearchCategoryName, storeId: "", pageIndex: command.Page - 1, pageSize: command.PageSize, showHidden: true); var items = new List(); foreach (var item in categories) diff --git a/src/Web/Grand.Web.Admin/Controllers/SearchController.cs b/src/Web/Grand.Web.Admin/Controllers/SearchController.cs index 332e80e4b..4c649a990 100644 --- a/src/Web/Grand.Web.Admin/Controllers/SearchController.cs +++ b/src/Web/Grand.Web.Admin/Controllers/SearchController.cs @@ -90,7 +90,7 @@ public async Task Index(string searchTerm, FoundMenuItem[] foundM if (result.Count < _adminSearchSettings.MaxSearchResultsCount && _adminSearchSettings.SearchInCategories) { - var categories = await _categoryService.GetAllCategories(categoryName: searchTerm, + var categories = await _categoryService.GetAllCategories(parentId: null, categoryName: searchTerm, storeId: "", pageSize: _adminSearchSettings.MaxSearchResultsCount - result.Count, showHidden: await _groupService.IsAdmin(_contextAccessor.WorkContext.CurrentCustomer)); foreach (var category in categories) @@ -104,7 +104,7 @@ public async Task Index(string searchTerm, FoundMenuItem[] foundM if (result.Count < _adminSearchSettings.MaxSearchResultsCount && _adminSearchSettings.SearchInCollections) { - var collections = await _collectionService.GetAllCollections(searchTerm, + var collections = await _collectionService.GetAllCollections(searchTerm, storeId: "", pageSize: _adminSearchSettings.MaxSearchResultsCount - result.Count, showHidden: true); foreach (var collection in collections) result.Add(new Tuple(new @@ -300,6 +300,7 @@ public async Task Brand(string brandId, DataSourceRequestFilter m { var brands = await _brandService.GetAllBrands( model.GetNameFilterValue(), + storeId: "", pageSize: _adminSearchSettings.BrandSizeLimit); var gridModel = await DataSourceResultHelper.GetSearchResult(brandId, brands, brand => Task.FromResult(brand.Name)); diff --git a/src/Web/Grand.Web.AdminShared/Services/CategoryViewModelService.cs b/src/Web/Grand.Web.AdminShared/Services/CategoryViewModelService.cs index 9ff867537..d9f60512c 100644 --- a/src/Web/Grand.Web.AdminShared/Services/CategoryViewModelService.cs +++ b/src/Web/Grand.Web.AdminShared/Services/CategoryViewModelService.cs @@ -76,6 +76,7 @@ public virtual async Task PrepareCategoryListModel(string sto CategoryListModel model, int pageIndex, int pageSize) { var categories = await _categoryService.GetAllCategories( + parentId: null, categoryName: model.SearchCategoryName, storeId: model.SearchStoreId, pageSize: pageSize, diff --git a/src/Web/Grand.Web.AdminShared/Services/CollectionViewModelService.cs b/src/Web/Grand.Web.AdminShared/Services/CollectionViewModelService.cs index 530b5d63d..c116f72c9 100644 --- a/src/Web/Grand.Web.AdminShared/Services/CollectionViewModelService.cs +++ b/src/Web/Grand.Web.AdminShared/Services/CollectionViewModelService.cs @@ -181,7 +181,8 @@ public virtual async Task DeleteCollection(Collection collection) //collections model.AvailableCollections.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = " " }); - foreach (var m in await _collectionService.GetAllCollections(showHidden: true)) + foreach (var m in await _collectionService.GetAllCollections(collectionName: "", storeId: "", + showHidden: true)) model.AvailableCollections.Add(new SelectListItem { Text = m.Name, Value = m.Id }); //stores diff --git a/src/Web/Grand.Web.Store/Controllers/DiscountController.cs b/src/Web/Grand.Web.Store/Controllers/DiscountController.cs index eddbc4cd2..c46479ffc 100644 --- a/src/Web/Grand.Web.Store/Controllers/DiscountController.cs +++ b/src/Web/Grand.Web.Store/Controllers/DiscountController.cs @@ -1,4 +1,4 @@ -using Grand.Business.Core.Interfaces.Catalog.Brands; +using Grand.Business.Core.Interfaces.Catalog.Brands; using Grand.Business.Core.Interfaces.Catalog.Categories; using Grand.Business.Core.Interfaces.Catalog.Collections; using Grand.Business.Core.Interfaces.Catalog.Discounts; @@ -515,7 +515,7 @@ public IActionResult CategoryAddPopup(string discountId) public async Task CategoryAddPopupList(DataSourceRequest command, DiscountModel.AddCategoryToDiscountModel model, [FromServices] ICategoryService categoryService) { - var categories = await categoryService.GetAllCategories(categoryName: model.SearchCategoryName, + var categories = await categoryService.GetAllCategories(parentId: null, categoryName: model.SearchCategoryName, storeId: CurrentStoreId, pageIndex: command.Page - 1, pageSize: command.PageSize, showHidden: true); var items = new List(); foreach (var item in categories) diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetBrandAllHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetBrandAllHandler.cs index f99800fd1..1fbe7fdc3 100644 --- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetBrandAllHandler.cs +++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetBrandAllHandler.cs @@ -47,7 +47,7 @@ private async Task> PrepareBrands(GetBrandAll request, BrandLis request.Command.PageSize = _catalogSettings.MaxCatalogPageSize; var model = new List(); - var brands = await _brandService.GetAllBrands(storeId: request.Store.Id, + var brands = await _brandService.GetAllBrands(brandName: "", storeId: request.Store.Id, pageIndex: request.Command.PageNumber - 1, pageSize: request.Command.PageSize ); diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategoryAllHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategoryAllHandler.cs index 125b5a10f..829f44813 100644 --- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategoryAllHandler.cs +++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategoryAllHandler.cs @@ -48,7 +48,7 @@ private async Task> PrepareCategories(GetCategoryAll request request.Command.PageSize = _catalogSettings.MaxCatalogPageSize; var model = new List(); - var categories = await _categoryService.GetAllCategories(storeId: request.Store.Id, + var categories = await _categoryService.GetAllCategories(parentId: null, categoryName: "", storeId: request.Store.Id, pageIndex: request.Command.PageNumber - 1, pageSize: request.Command.PageSize ); diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategorySimpleHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategorySimpleHandler.cs index c20d4560b..dc5e72f90 100644 --- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategorySimpleHandler.cs +++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategorySimpleHandler.cs @@ -65,7 +65,7 @@ private async Task> PrepareCategorySimpleModels(GetCat async Task PrepareCategories(string categoryId) { - var parentCategories = await _categoryService.GetAllCategories(categoryId, storeId: request.Store.Id); + var parentCategories = await _categoryService.GetAllCategories(categoryId, categoryName: "", storeId: request.Store.Id); if (parentCategories.Any()) { categories.AddRange(parentCategories); @@ -79,7 +79,7 @@ async Task PrepareCategories(string categoryId) if (currentCategory != null) { var currentCategories = - await _categoryService.GetAllCategories(currentCategory.Id, storeId: request.Store.Id); + await _categoryService.GetAllCategories(currentCategory.Id, categoryName: "", storeId: request.Store.Id); categories.AddRange(currentCategories); await PrepareCategories(currentCategory.ParentCategoryId); } diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCollectionAllHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCollectionAllHandler.cs index 75bdf8e9b..ba4c3912d 100644 --- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCollectionAllHandler.cs +++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCollectionAllHandler.cs @@ -48,7 +48,7 @@ private async Task> PrepareCollectionAll(GetCollectionAll request.Command.PageSize = _catalogSettings.MaxCatalogPageSize; var model = new List(); - var collections = await _collectionService.GetAllCollections(storeId: request.Store.Id, + var collections = await _collectionService.GetAllCollections(collectionName: "", storeId: request.Store.Id, pageIndex: request.Command.PageNumber - 1, pageSize: request.Command.PageSize); diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCollectionNavigationHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCollectionNavigationHandler.cs index df5254db4..8aeb58593 100644 --- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCollectionNavigationHandler.cs +++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCollectionNavigationHandler.cs @@ -35,7 +35,7 @@ public async Task Handle(GetCollectionNavigation requ { var currentCollection = await _collectionService.GetCollectionById(request.CurrentCollectionId); var collections = - await _collectionService.GetAllCollections(pageSize: _catalogSettings.CollectionsBlockItemsToDisplay, + await _collectionService.GetAllCollections(collectionName: "", pageSize: _catalogSettings.CollectionsBlockItemsToDisplay, storeId: request.Store.Id); var model = new CollectionNavigationModel { TotalCollections = collections.TotalCount diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetHomepageBrandsHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetHomepageBrandsHandler.cs index 81fb2b4a7..7d253d9d9 100644 --- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetHomepageBrandsHandler.cs +++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetHomepageBrandsHandler.cs @@ -41,7 +41,7 @@ public async Task> Handle(GetHomepageBrands request, Cancellat var model = await _cacheBase.GetAsync(brandsCacheKey, async () => { var modelBrands = new List(); - var allBrands = await _brandService.GetAllBrands(storeId: request.Store.Id); + var allBrands = await _brandService.GetAllBrands(brandName: "", storeId: request.Store.Id); foreach (var x in allBrands.Where(x => x.ShowOnHomePage)) { var brandModel = x.ToModel(request.Language); diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetHomepageCollectionsHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetHomepageCollectionsHandler.cs index be8e0c12c..4f5123e79 100644 --- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetHomepageCollectionsHandler.cs +++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetHomepageCollectionsHandler.cs @@ -43,7 +43,7 @@ public async Task> Handle(GetHomepageCollections request, var model = await _cacheBase.GetAsync(collectionsCacheKey, async () => { var modelCollect = new List(); - var allcollections = await _collectionService.GetAllCollections(storeId: request.Store.Id); + var allcollections = await _collectionService.GetAllCollections(collectionName: "", storeId: request.Store.Id); foreach (var x in allcollections.Where(x => x.ShowOnHomePage)) { var _model = x.ToModel(request.Language); diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetMenuHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetMenuHandler.cs index 34c7ff2d3..0aaddc9a7 100644 --- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetMenuHandler.cs +++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetMenuHandler.cs @@ -79,7 +79,7 @@ public async Task Handle(GetMenu request, CancellationToken cancellat request.Language.Id, request.Store.Id); var cachedBrandModel = await _cacheBase.GetAsync(brandCacheKey, async () => - (await _brandService.GetAllBrands(storeId: request.Store.Id)) + (await _brandService.GetAllBrands(brandName: "", storeId: request.Store.Id)) .Where(x => x.IncludeInMenu) .Select(t => new MenuModel.MenuBrandModel { Id = t.Id, @@ -94,7 +94,7 @@ public async Task Handle(GetMenu request, CancellationToken cancellat request.Language.Id, request.Store.Id); var cachedCollectionModel = await _cacheBase.GetAsync(collectionCacheKey, async () => - (await _collectionService.GetAllCollections(storeId: request.Store.Id)) + (await _collectionService.GetAllCollections(collectionName: "", storeId: request.Store.Id)) .Where(x => x.IncludeInMenu) .Select(t => new MenuModel.MenuCollectionModel { Id = t.Id, diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetSearchHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetSearchHandler.cs index d77864c19..0c2921b6d 100644 --- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetSearchHandler.cs +++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetSearchHandler.cs @@ -99,7 +99,7 @@ public async Task Handle(GetSearch request, CancellationToken cance { var categoriesModel = new List(); //all categories - var allCategories = await _categoryService.GetAllCategories(storeId: request.Store.Id, pageSize: 100); + var allCategories = await _categoryService.GetAllCategories(parentId: null, categoryName: "", storeId: request.Store.Id, pageSize: 100); foreach (var c in allCategories) { //generate full category name (breadcrumb) @@ -136,7 +136,7 @@ public async Task Handle(GetSearch request, CancellationToken cance }); } - var collections = await _collectionService.GetAllCollections(pageSize: 100); + var collections = await _collectionService.GetAllCollections(collectionName: "", storeId: request.Store.Id, pageSize: 100); if (collections.Any()) { request.Model.AvailableCollections.Add(new SelectListItem { diff --git a/src/Web/Grand.Web/Features/Handlers/Common/GetSitemapHandler.cs b/src/Web/Grand.Web/Features/Handlers/Common/GetSitemapHandler.cs index 9ec7f376b..c7fe3c4cf 100644 --- a/src/Web/Grand.Web/Features/Handlers/Common/GetSitemapHandler.cs +++ b/src/Web/Grand.Web/Features/Handlers/Common/GetSitemapHandler.cs @@ -78,14 +78,14 @@ public async Task Handle(GetSitemap request, CancellationToken can //categories if (_commonSettings.SitemapIncludeCategories) { - var categories = await _categoryService.GetAllCategories(storeId: request.Store.Id); + var categories = await _categoryService.GetAllCategories(parentId: null, categoryName: "", storeId: request.Store.Id); model.Categories = categories.Select(x => x.ToModel(request.Language)).ToList(); } //collections if (_commonSettings.SitemapIncludeBrands) { - var brands = await _brandService.GetAllBrands(storeId: request.Store.Id); + var brands = await _brandService.GetAllBrands(brandName: "", storeId: request.Store.Id); model.Brands = brands.Select(x => x.ToModel(request.Language)).ToList(); }