diff --git a/src/Libraries/Nop.Services/Catalog/IProductAttributeService.cs b/src/Libraries/Nop.Services/Catalog/IProductAttributeService.cs index bf5650ea504..ae91013effc 100644 --- a/src/Libraries/Nop.Services/Catalog/IProductAttributeService.cs +++ b/src/Libraries/Nop.Services/Catalog/IProductAttributeService.cs @@ -29,11 +29,12 @@ public partial interface IProductAttributeService /// /// Page index /// Page size + /// Filter by name /// /// A task that represents the asynchronous operation /// The task result contains the product attributes /// - Task> GetAllProductAttributesAsync(int pageIndex = 0, int pageSize = int.MaxValue); + Task> GetAllProductAttributesAsync(int pageIndex = 0, int pageSize = int.MaxValue, string name = ""); /// /// Gets a product attribute diff --git a/src/Libraries/Nop.Services/Catalog/ProductAttributeService.cs b/src/Libraries/Nop.Services/Catalog/ProductAttributeService.cs index 16055e6880b..d072ab3174a 100644 --- a/src/Libraries/Nop.Services/Catalog/ProductAttributeService.cs +++ b/src/Libraries/Nop.Services/Catalog/ProductAttributeService.cs @@ -88,21 +88,20 @@ public virtual async Task DeleteProductAttributesAsync(IList p /// /// Page index /// Page size + /// Filter by name /// /// A task that represents the asynchronous operation /// The task result contains the product attributes /// public virtual async Task> GetAllProductAttributesAsync(int pageIndex = 0, - int pageSize = int.MaxValue) + int pageSize = int.MaxValue, string name = "") { - var productAttributes = await _productAttributeRepository.GetAllPagedAsync(query => - { - return from pa in query - orderby pa.Name - select pa; - }, pageIndex, pageSize); + var query = _productAttributeRepository.Table; + + if (!string.IsNullOrWhiteSpace(name)) + query = query.Where(pa => pa.Name.Contains(name)); - return productAttributes; + return await query.OrderBy(x => x.Name).ToPagedListAsync(pageIndex, pageSize); } /// diff --git a/src/Presentation/Nop.Web.Framework/Migrations/UpgradeTo490/LocalizationMigration.cs b/src/Presentation/Nop.Web.Framework/Migrations/UpgradeTo490/LocalizationMigration.cs index cdeee681c83..4d1896dd860 100644 --- a/src/Presentation/Nop.Web.Framework/Migrations/UpgradeTo490/LocalizationMigration.cs +++ b/src/Presentation/Nop.Web.Framework/Migrations/UpgradeTo490/LocalizationMigration.cs @@ -57,6 +57,10 @@ public override void Up() //#7398 ["Admin.ConfigurationSteps.Product.Details.Text"] = "Enter the relevant product details in these fields. The screenshot below shows how they will be displayed on the product page with the default nopCommerce theme:
", ["Admin.ConfigurationSteps.PaymentPayPal.ApiCredentials.Text"] = "If you already have an app created in your PayPal account, follow these steps.", + + //#7515 + ["Admin.Catalog.Attributes.ProductAttributes.List.SearchProductAttributeName"] = "Product attribute name", + ["Admin.Catalog.Attributes.ProductAttributes.List.SearchProductAttributeName.Hint"] = "A Product attribute name.", }, languageId); #endregion diff --git a/src/Presentation/Nop.Web/App_Data/Localization/defaultResources.nopres.xml b/src/Presentation/Nop.Web/App_Data/Localization/defaultResources.nopres.xml index e3a3125bbff..2d6d119cda0 100644 --- a/src/Presentation/Nop.Web/App_Data/Localization/defaultResources.nopres.xml +++ b/src/Presentation/Nop.Web/App_Data/Localization/defaultResources.nopres.xml @@ -1956,6 +1956,12 @@ Published + + Product attribute name + + + A Product attribute name. + Specification attributes diff --git a/src/Presentation/Nop.Web/Areas/Admin/Controllers/ProductAttributeController.cs b/src/Presentation/Nop.Web/Areas/Admin/Controllers/ProductAttributeController.cs index 42d83b1d703..422d15b2f8d 100644 --- a/src/Presentation/Nop.Web/Areas/Admin/Controllers/ProductAttributeController.cs +++ b/src/Presentation/Nop.Web/Areas/Admin/Controllers/ProductAttributeController.cs @@ -25,7 +25,7 @@ public partial class ProductAttributeController : BaseAdminController protected readonly IProductAttributeModelFactory _productAttributeModelFactory; protected readonly IProductAttributeService _productAttributeService; - #endregion Fields + #endregion Fields #region Ctor diff --git a/src/Presentation/Nop.Web/Areas/Admin/Factories/ProductAttributeModelFactory.cs b/src/Presentation/Nop.Web/Areas/Admin/Factories/ProductAttributeModelFactory.cs index e2ef1f6fa12..2c1f1657366 100644 --- a/src/Presentation/Nop.Web/Areas/Admin/Factories/ProductAttributeModelFactory.cs +++ b/src/Presentation/Nop.Web/Areas/Admin/Factories/ProductAttributeModelFactory.cs @@ -117,7 +117,7 @@ public virtual async Task PrepareProductAttributeList //get product attributes var productAttributes = await _productAttributeService - .GetAllProductAttributesAsync(pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize); + .GetAllProductAttributesAsync(pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize, name: searchModel.SearchProductAttributeName); //prepare list model var model = new ProductAttributeListModel().PrepareToGrid(searchModel, productAttributes, () => diff --git a/src/Presentation/Nop.Web/Areas/Admin/Models/Catalog/ProductAttributeSearchModel.cs b/src/Presentation/Nop.Web/Areas/Admin/Models/Catalog/ProductAttributeSearchModel.cs index b35b3142d3e..d22a2a50655 100644 --- a/src/Presentation/Nop.Web/Areas/Admin/Models/Catalog/ProductAttributeSearchModel.cs +++ b/src/Presentation/Nop.Web/Areas/Admin/Models/Catalog/ProductAttributeSearchModel.cs @@ -1,4 +1,5 @@ using Nop.Web.Framework.Models; +using Nop.Web.Framework.Mvc.ModelBinding; namespace Nop.Web.Areas.Admin.Models.Catalog; @@ -7,4 +8,6 @@ namespace Nop.Web.Areas.Admin.Models.Catalog; ///
public partial record ProductAttributeSearchModel : BaseSearchModel { + [NopResourceDisplayName("Admin.Catalog.Attributes.ProductAttributes.List.SearchProductAttributeName")] + public string SearchProductAttributeName { get; set; } } \ No newline at end of file diff --git a/src/Presentation/Nop.Web/Areas/Admin/Views/ProductAttribute/List.cshtml b/src/Presentation/Nop.Web/Areas/Admin/Views/ProductAttribute/List.cshtml index f13c40e1c87..16289e0b8e2 100644 --- a/src/Presentation/Nop.Web/Areas/Admin/Views/ProductAttribute/List.cshtml +++ b/src/Presentation/Nop.Web/Areas/Admin/Views/ProductAttribute/List.cshtml @@ -7,96 +7,141 @@ NopHtml.SetActiveMenuItemSystemName("Product attributes"); } - -
-

- @T("Admin.Catalog.Attributes.ProductAttributes") -

-
- - - @T("Admin.Common.AddNew") - - @await Component.InvokeAsync(typeof(AdminWidgetViewComponent), new { widgetZone = AdminWidgetZones.ProductAttributeListButtons, additionalData = Model }) - - +@{ + const string hideSearchBlockAttributeName = "ProductAttributeListPage.HideSearchBlock"; + var hideSearchBlock = await genericAttributeService.GetAttributeAsync(await workContext.GetCurrentCustomerAsync(), hideSearchBlockAttributeName); +} +
+
+

+ @T("Admin.Catalog.Attributes.ProductAttributes") +

+
+ + + @T("Admin.Common.AddNew") + + @await Component.InvokeAsync(typeof(AdminWidgetViewComponent), new { widgetZone = AdminWidgetZones.ProductAttributeListButtons, additionalData = Model }) + + +
-
-
-
-
-
-
-

- @T("Admin.Catalog.Attributes.ProductAttributes.Description") - -

- @await Html.PartialAsync("Table", new DataTablesModel - { - Name = "products-grid", - UrlRead = new DataUrl("List", "ProductAttribute", null), - Length = Model.PageSize, - LengthMenu = Model.AvailablePageSizes, - ColumnCollection = new List - { - new ColumnProperty(nameof(ProductAttributeModel.Id)) - { +
+
+
+
+ + +
+
+

+ @T("Admin.Catalog.Attributes.ProductAttributes.Description") + +

+ @await Html.PartialAsync("Table", new DataTablesModel + { + Name = "products-grid", + UrlRead = new DataUrl("List", "ProductAttribute", null), + SearchButtonId = "search-productattributes", + Length = Model.PageSize, + LengthMenu = Model.AvailablePageSizes, + Filters = new List + { + new FilterParameter(nameof(Model.SearchProductAttributeName)) + }, + ColumnCollection = new List + { + new ColumnProperty(nameof(ProductAttributeModel.Id)) + { IsMasterCheckBox = true, Render = new RenderCheckBox("checkbox_productattributes"), ClassName = NopColumnClassDefaults.CenterAll, Width = "50" - }, - new ColumnProperty(nameof(ProductAttributeModel.Name)) - { + }, + new ColumnProperty(nameof(ProductAttributeModel.Name)) + { Title = T("Admin.Catalog.Attributes.ProductAttributes.Fields.Name").Text - }, - new ColumnProperty(nameof(ProductAttributeModel.Id)) - { + }, + new ColumnProperty(nameof(ProductAttributeModel.Id)) + { Title = T("Admin.Common.Edit").Text, Width = "100", ClassName = NopColumnClassDefaults.Button, Render = new RenderButtonEdit(new DataUrl("~/Admin/ProductAttribute/Edit")) - } - } - }) + } + } + }) - - - + + + +
+
+
-
-
-
\ No newline at end of file + + \ No newline at end of file