diff --git a/Presentation/Nop.Web/Factories/CatalogModelFactory.cs b/Presentation/Nop.Web/Factories/CatalogModelFactory.cs index f2df439..a894826 100644 --- a/Presentation/Nop.Web/Factories/CatalogModelFactory.cs +++ b/Presentation/Nop.Web/Factories/CatalogModelFactory.cs @@ -363,7 +363,7 @@ public partial class CatalogModelFactory : ICatalogModelFactory model.NoResultMessage = await _localizationService.GetResourceAsync("Catalog.Products.NoResult"); else { - model.Products = (await _productModelFactory.PrepareProductDetailsModelsAsync(products)).ToList(); + model.Products = (await _productModelFactory.PrepareProductOverviewModelsAsync(products)).ToList(); model.LoadPagedList(products); } } diff --git a/Presentation/Nop.Web/Factories/IProductModelFactory.cs b/Presentation/Nop.Web/Factories/IProductModelFactory.cs index de0e2da..f890318 100644 --- a/Presentation/Nop.Web/Factories/IProductModelFactory.cs +++ b/Presentation/Nop.Web/Factories/IProductModelFactory.cs @@ -35,10 +35,7 @@ public partial interface IProductModelFactory Task> PrepareProductOverviewModelsAsync(IEnumerable products, bool preparePriceModel = true, bool preparePictureModel = true, int? productThumbPictureSize = null, bool prepareSpecificationAttributes = false, - bool forceRedirectionAfterAddingToCart = false); - - //TODO - A. - Task> PrepareProductDetailsModelsAsync(IEnumerable products); + bool forceRedirectionAfterAddingToCart = false); /// /// Prepare the product combination models diff --git a/Presentation/Nop.Web/Factories/ProductModelFactory.cs b/Presentation/Nop.Web/Factories/ProductModelFactory.cs index b95cde7..fb2d1cd 100644 --- a/Presentation/Nop.Web/Factories/ProductModelFactory.cs +++ b/Presentation/Nop.Web/Factories/ProductModelFactory.cs @@ -1404,28 +1404,13 @@ public partial class ProductModelFactory : IProductModelFactory //reviews model.ReviewOverviewModel = await PrepareProductReviewOverviewModelAsync(product); + model.Manufacturers = await PrepareProductManufacturerModelsAsync(product); // ADDED - A. models.Add(model); } return models; - } - - //TODO - A. - public virtual async Task> PrepareProductDetailsModelsAsync(IEnumerable products) - { - ArgumentNullException.ThrowIfNull(products); - - var models = new List(); - foreach (var product in products) - { - var model = await PrepareProductDetailsModelAsync(product); - - models.Add(model); - } - - return models; - } + } /// /// Prepare the product combination models diff --git a/Presentation/Nop.Web/Models/Catalog/CatalogProductsModel.cs b/Presentation/Nop.Web/Models/Catalog/CatalogProductsModel.cs index 0c7671b..8cb9aeb 100644 --- a/Presentation/Nop.Web/Models/Catalog/CatalogProductsModel.cs +++ b/Presentation/Nop.Web/Models/Catalog/CatalogProductsModel.cs @@ -83,7 +83,7 @@ public partial record CatalogProductsModel : BasePageableModel /// /// Gets or sets the products /// - public IList Products { get; set; } + public IList Products { get; set; } #endregion @@ -97,7 +97,7 @@ public partial record CatalogProductsModel : BasePageableModel AvailableSortOptions = new List(); AvailableViewModes = new List(); PageSizeOptions = new List(); - Products = new List(); + Products = new List(); } #endregion diff --git a/Presentation/Nop.Web/Models/Catalog/ProductOverviewModel.cs b/Presentation/Nop.Web/Models/Catalog/ProductOverviewModel.cs index 26fba0b..4cf706c 100644 --- a/Presentation/Nop.Web/Models/Catalog/ProductOverviewModel.cs +++ b/Presentation/Nop.Web/Models/Catalog/ProductOverviewModel.cs @@ -12,11 +12,13 @@ public partial record ProductOverviewModel : BaseNopEntityModel PictureModels = new List(); ProductSpecificationModel = new ProductSpecificationModel(); ReviewOverviewModel = new ProductReviewOverviewModel(); + Manufacturers = new List(); // ADDED - A. } public string Name { get; set; } public string ShortDescription { get; set; } public string FullDescription { get; set; } + public string SeName { get; set; } public string Sku { get; set; } @@ -33,6 +35,7 @@ public partial record ProductOverviewModel : BaseNopEntityModel public ProductSpecificationModel ProductSpecificationModel { get; set; } //price public ProductReviewOverviewModel ReviewOverviewModel { get; set; } + public IList Manufacturers { get; set; } // ADDED - A. #region Nested Classes diff --git a/Presentation/Nop.Web/Themes/Cypher_Bootstrap5/Views/Shared/_ProductBox.cshtml b/Presentation/Nop.Web/Themes/Cypher_Bootstrap5/Views/Shared/_ProductBox.cshtml index 3c2d109..8a7fcf7 100644 --- a/Presentation/Nop.Web/Themes/Cypher_Bootstrap5/Views/Shared/_ProductBox.cshtml +++ b/Presentation/Nop.Web/Themes/Cypher_Bootstrap5/Views/Shared/_ProductBox.cshtml @@ -1,8 +1,9 @@ -@model ProductDetailsModel +@model ProductOverviewModel @using Nop.Core @using Nop.Core.Domain.Catalog @using Nop.Core.Domain.Orders @using Nop.Core.Domain.Tax +@using System.Web @inject CatalogSettings catalogSettings @inject IWorkContext workContext @{ @@ -10,14 +11,14 @@ var addtocartlink = ""; var shoppingCartTypeId = (int)ShoppingCartType.ShoppingCart; var quantity = 1; - // if (Model.ProductPrice.ForceRedirectionAfterAddingToCart) - // { - // addtocartlink = Url.RouteUrl("AddProductToCart-Catalog", new { productId = Model.Id, shoppingCartTypeId = shoppingCartTypeId, quantity = quantity, forceredirection = Model.ProductPrice.ForceRedirectionAfterAddingToCart }); - // } - // else - // { + if (Model.ProductPrice.ForceRedirectionAfterAddingToCart) + { + addtocartlink = Url.RouteUrl("AddProductToCart-Catalog", new { productId = Model.Id, shoppingCartTypeId = shoppingCartTypeId, quantity = quantity, forceredirection = Model.ProductPrice.ForceRedirectionAfterAddingToCart }); + } + else + { addtocartlink = Url.RouteUrl("AddProductToCart-Catalog", new { productId = Model.Id, shoppingCartTypeId = shoppingCartTypeId, quantity = quantity }); - // } + } var addtowishlistlink = Url.RouteUrl("AddProductToCart-Catalog", new { productId = Model.Id, shoppingCartTypeId = (int)ShoppingCartType.Wishlist, quantity = quantity }); var addtocomparelink = Url.RouteUrl("AddProductToCompare", new { productId = Model.Id }); @@ -60,10 +61,10 @@

@Model.Name

- @if(Model.ProductManufacturers.Count > 0) + @if (Model.Manufacturers.Count > 0) // ADDED - A. { string manufacturers = ""; - foreach(var manu in Model.ProductManufacturers) + foreach(var manu in Model.Manufacturers) { manufacturers = manufacturers + manu.Name + ";"; } @@ -75,14 +76,14 @@ @Model.Sku } - @if (Model.ProductReviewOverview.AllowCustomerReviews) + @if (Model.ReviewOverviewModel.AllowCustomerReviews) { var ratingPercent = 0; - if (Model.ProductReviewOverview.TotalReviews != 0) + if (Model.ReviewOverviewModel.TotalReviews != 0) { - ratingPercent = ((Model.ProductReviewOverview.RatingSum * 100) / Model.ProductReviewOverview.TotalReviews) / 5; + ratingPercent = ((Model.ReviewOverviewModel.RatingSum * 100) / Model.ReviewOverviewModel.TotalReviews) / 5; } -
+
@@ -90,7 +91,7 @@
}
- @Html.Raw(Model.ShortDescription) + @Html.Raw(HttpUtility.HtmlDecode(Model.ShortDescription))
@await Component.InvokeAsync(typeof(WidgetViewComponent), new { widgetZone = PublicWidgetZones.ProductBoxAddinfoBefore, additionalData = Model }) @@ -119,25 +120,25 @@ @await Component.InvokeAsync(typeof(WidgetViewComponent), new { widgetZone = PublicWidgetZones.ProductBoxAddinfoMiddle, additionalData = Model })
@**@ - @if (!Model.AddToCart.DisableBuyButton) + @if (!Model.ProductPrice.DisableBuyButton) { var addToCartText = T("ShoppingCart.AddToCart").Text; if (Model.ProductPrice.IsRental) { addToCartText = T("ShoppingCart.Rent").Text; } - if (Model.AddToCart.AvailableForPreOrder) + if (Model.ProductPrice.AvailableForPreOrder) { addToCartText = T("ShoppingCart.PreOrder").Text; } } - @if (Model.CompareProductsEnabled) + @if (!Model.ProductPrice.DisableAddToCompareListButton) { } - @if (!Model.AddToCart.DisableWishlistButton) + @if (!Model.ProductPrice.DisableWishlistButton) { }