diff --git a/Presentation/Nop.Web/Factories/CatalogModelFactory.cs b/Presentation/Nop.Web/Factories/CatalogModelFactory.cs index a894826..f2df439 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.PrepareProductOverviewModelsAsync(products)).ToList(); + model.Products = (await _productModelFactory.PrepareProductDetailsModelsAsync(products)).ToList(); model.LoadPagedList(products); } } diff --git a/Presentation/Nop.Web/Factories/IProductModelFactory.cs b/Presentation/Nop.Web/Factories/IProductModelFactory.cs index 574a7ac..de0e2da 100644 --- a/Presentation/Nop.Web/Factories/IProductModelFactory.cs +++ b/Presentation/Nop.Web/Factories/IProductModelFactory.cs @@ -37,6 +37,9 @@ public partial interface IProductModelFactory int? productThumbPictureSize = null, bool prepareSpecificationAttributes = false, bool forceRedirectionAfterAddingToCart = false); + //TODO - A. + Task> PrepareProductDetailsModelsAsync(IEnumerable products); + /// /// Prepare the product combination models /// diff --git a/Presentation/Nop.Web/Factories/ProductModelFactory.cs b/Presentation/Nop.Web/Factories/ProductModelFactory.cs index bb8a048..b95cde7 100644 --- a/Presentation/Nop.Web/Factories/ProductModelFactory.cs +++ b/Presentation/Nop.Web/Factories/ProductModelFactory.cs @@ -1411,6 +1411,22 @@ public partial class ProductModelFactory : IProductModelFactory 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 8cb9aeb..0c7671b 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/Themes/Cypher_Bootstrap5/Views/Shared/_ProductBox.cshtml b/Presentation/Nop.Web/Themes/Cypher_Bootstrap5/Views/Shared/_ProductBox.cshtml index 59a2a43..3c2d109 100644 --- a/Presentation/Nop.Web/Themes/Cypher_Bootstrap5/Views/Shared/_ProductBox.cshtml +++ b/Presentation/Nop.Web/Themes/Cypher_Bootstrap5/Views/Shared/_ProductBox.cshtml @@ -1,4 +1,4 @@ -@model ProductOverviewModel +@model ProductDetailsModel @using Nop.Core @using Nop.Core.Domain.Catalog @using Nop.Core.Domain.Orders @@ -10,14 +10,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,20 +60,29 @@

@Model.Name

+ @if(Model.ProductManufacturers.Count > 0) + { + string manufacturers = ""; + foreach(var manu in Model.ProductManufacturers) + { + manufacturers = manufacturers + manu.Name + ";"; + } +

@manufacturers

+ } @if (catalogSettings.ShowSkuOnCatalogPages && !string.IsNullOrEmpty(Model.Sku)) {
@Model.Sku
} - @if (Model.ReviewOverviewModel.AllowCustomerReviews) + @if (Model.ProductReviewOverview.AllowCustomerReviews) { var ratingPercent = 0; - if (Model.ReviewOverviewModel.TotalReviews != 0) + if (Model.ProductReviewOverview.TotalReviews != 0) { - ratingPercent = ((Model.ReviewOverviewModel.RatingSum*100)/Model.ReviewOverviewModel.TotalReviews)/5; + ratingPercent = ((Model.ProductReviewOverview.RatingSum * 100) / Model.ProductReviewOverview.TotalReviews) / 5; } -
+
@@ -110,25 +119,25 @@ @await Component.InvokeAsync(typeof(WidgetViewComponent), new { widgetZone = PublicWidgetZones.ProductBoxAddinfoMiddle, additionalData = Model })
@**@ - @if (!Model.ProductPrice.DisableBuyButton) + @if (!Model.AddToCart.DisableBuyButton) { var addToCartText = T("ShoppingCart.AddToCart").Text; if (Model.ProductPrice.IsRental) { addToCartText = T("ShoppingCart.Rent").Text; } - if (Model.ProductPrice.AvailableForPreOrder) + if (Model.AddToCart.AvailableForPreOrder) { addToCartText = T("ShoppingCart.PreOrder").Text; } } - @if (!Model.ProductPrice.DisableAddToCompareListButton) + @if (Model.CompareProductsEnabled) { } - @if (!Model.ProductPrice.DisableWishlistButton) + @if (!Model.AddToCart.DisableWishlistButton) { }