revert productdetailsmoddel, extend productoverviewmodel, bid "ding"
This commit is contained in:
parent
3cf0562759
commit
5508e32e53
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,9 +37,6 @@ public partial interface IProductModelFactory
|
|||
int? productThumbPictureSize = null, bool prepareSpecificationAttributes = false,
|
||||
bool forceRedirectionAfterAddingToCart = false);
|
||||
|
||||
//TODO - A.
|
||||
Task<IEnumerable<ProductDetailsModel>> PrepareProductDetailsModelsAsync(IEnumerable<Product> products);
|
||||
|
||||
/// <summary>
|
||||
/// Prepare the product combination models
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -1404,22 +1404,7 @@ public partial class ProductModelFactory : IProductModelFactory
|
|||
|
||||
//reviews
|
||||
model.ReviewOverviewModel = await PrepareProductReviewOverviewModelAsync(product);
|
||||
|
||||
models.Add(model);
|
||||
}
|
||||
|
||||
return models;
|
||||
}
|
||||
|
||||
//TODO - A.
|
||||
public virtual async Task<IEnumerable<ProductDetailsModel>> PrepareProductDetailsModelsAsync(IEnumerable<Product> products)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(products);
|
||||
|
||||
var models = new List<ProductDetailsModel>();
|
||||
foreach (var product in products)
|
||||
{
|
||||
var model = await PrepareProductDetailsModelAsync(product);
|
||||
model.Manufacturers = await PrepareProductManufacturerModelsAsync(product); // ADDED - A.
|
||||
|
||||
models.Add(model);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ public partial record CatalogProductsModel : BasePageableModel
|
|||
/// <summary>
|
||||
/// Gets or sets the products
|
||||
/// </summary>
|
||||
public IList<ProductDetailsModel> Products { get; set; }
|
||||
public IList<ProductOverviewModel> Products { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ public partial record CatalogProductsModel : BasePageableModel
|
|||
AvailableSortOptions = new List<SelectListItem>();
|
||||
AvailableViewModes = new List<SelectListItem>();
|
||||
PageSizeOptions = new List<SelectListItem>();
|
||||
Products = new List<ProductDetailsModel>();
|
||||
Products = new List<ProductOverviewModel>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -12,11 +12,13 @@ public partial record ProductOverviewModel : BaseNopEntityModel
|
|||
PictureModels = new List<PictureModel>();
|
||||
ProductSpecificationModel = new ProductSpecificationModel();
|
||||
ReviewOverviewModel = new ProductReviewOverviewModel();
|
||||
Manufacturers = new List<ManufacturerBriefInfoModel>(); // 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<ManufacturerBriefInfoModel> Manufacturers { get; set; } // ADDED - A.
|
||||
|
||||
#region Nested Classes
|
||||
|
||||
|
|
|
|||
|
|
@ -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 @@
|
|||
<h2 class="product-title">
|
||||
<a href="@(Url.RouteUrl<Product>(new {SeName = Model.SeName }))">@Model.Name</a>
|
||||
</h2>
|
||||
@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
|
||||
</div>
|
||||
}
|
||||
@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;
|
||||
}
|
||||
<div class="product-rating-box" title="@string.Format(T("Reviews.TotalReviews").Text, Model.ProductReviewOverview.TotalReviews)">
|
||||
<div class="product-rating-box" title="@string.Format(T("Reviews.TotalReviews").Text, Model.ReviewOverviewModel.TotalReviews)">
|
||||
<div class="rating">
|
||||
<div style="width: @(ratingPercent)%">
|
||||
</div>
|
||||
|
|
@ -90,7 +91,7 @@
|
|||
</div>
|
||||
}
|
||||
<div class="description" @(catalogSettings.ShowShortDescriptionOnCatalogPages ? "" : "data-short-description=none")>
|
||||
@Html.Raw(Model.ShortDescription)
|
||||
@Html.Raw(HttpUtility.HtmlDecode(Model.ShortDescription))
|
||||
</div>
|
||||
<div class="add-info">
|
||||
@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 })
|
||||
<div class="buttons">
|
||||
@*<button type="button" class="button-1 product-box-detail-button" onclick="setLocation('@Url.RouteUrl("Product", new { SeName = Model.SeName })')">@T("Products.Details")</button>*@
|
||||
@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;
|
||||
}
|
||||
<button type="button" class="btn btn-primary product-box-add-to-cart-button" onclick="AjaxCart.addproducttocart_catalog('@addtocartlink');return false;">@(addToCartText)</button>
|
||||
}
|
||||
@if (Model.CompareProductsEnabled)
|
||||
@if (!Model.ProductPrice.DisableAddToCompareListButton)
|
||||
{
|
||||
|
||||
<button type="button" title="@T("ShoppingCart.AddToCompareList")" class="button-2 add-to-compare-list-button" onclick="AjaxCart.addproducttocomparelist('@addtocomparelink');return false;">@T("ShoppingCart.AddToCompareList")</button>
|
||||
}
|
||||
@if (!Model.AddToCart.DisableWishlistButton)
|
||||
@if (!Model.ProductPrice.DisableWishlistButton)
|
||||
{
|
||||
<button type="button" title="@T("ShoppingCart.AddToWishlist")" class="button-2 add-to-wishlist-button" onclick="AjaxCart.addproducttocart_catalog('@addtowishlistlink');return false;">@T("ShoppingCart.AddToWishlist")</button>
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue