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");
|
model.NoResultMessage = await _localizationService.GetResourceAsync("Catalog.Products.NoResult");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
model.Products = (await _productModelFactory.PrepareProductDetailsModelsAsync(products)).ToList();
|
model.Products = (await _productModelFactory.PrepareProductOverviewModelsAsync(products)).ToList();
|
||||||
model.LoadPagedList(products);
|
model.LoadPagedList(products);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,10 +35,7 @@ public partial interface IProductModelFactory
|
||||||
Task<IEnumerable<ProductOverviewModel>> PrepareProductOverviewModelsAsync(IEnumerable<Product> products,
|
Task<IEnumerable<ProductOverviewModel>> PrepareProductOverviewModelsAsync(IEnumerable<Product> products,
|
||||||
bool preparePriceModel = true, bool preparePictureModel = true,
|
bool preparePriceModel = true, bool preparePictureModel = true,
|
||||||
int? productThumbPictureSize = null, bool prepareSpecificationAttributes = false,
|
int? productThumbPictureSize = null, bool prepareSpecificationAttributes = false,
|
||||||
bool forceRedirectionAfterAddingToCart = false);
|
bool forceRedirectionAfterAddingToCart = false);
|
||||||
|
|
||||||
//TODO - A.
|
|
||||||
Task<IEnumerable<ProductDetailsModel>> PrepareProductDetailsModelsAsync(IEnumerable<Product> products);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Prepare the product combination models
|
/// Prepare the product combination models
|
||||||
|
|
|
||||||
|
|
@ -1404,28 +1404,13 @@ public partial class ProductModelFactory : IProductModelFactory
|
||||||
|
|
||||||
//reviews
|
//reviews
|
||||||
model.ReviewOverviewModel = await PrepareProductReviewOverviewModelAsync(product);
|
model.ReviewOverviewModel = await PrepareProductReviewOverviewModelAsync(product);
|
||||||
|
model.Manufacturers = await PrepareProductManufacturerModelsAsync(product); // ADDED - A.
|
||||||
|
|
||||||
models.Add(model);
|
models.Add(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
return models;
|
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);
|
|
||||||
|
|
||||||
models.Add(model);
|
|
||||||
}
|
|
||||||
|
|
||||||
return models;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Prepare the product combination models
|
/// Prepare the product combination models
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ public partial record CatalogProductsModel : BasePageableModel
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the products
|
/// Gets or sets the products
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IList<ProductDetailsModel> Products { get; set; }
|
public IList<ProductOverviewModel> Products { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
@ -97,7 +97,7 @@ public partial record CatalogProductsModel : BasePageableModel
|
||||||
AvailableSortOptions = new List<SelectListItem>();
|
AvailableSortOptions = new List<SelectListItem>();
|
||||||
AvailableViewModes = new List<SelectListItem>();
|
AvailableViewModes = new List<SelectListItem>();
|
||||||
PageSizeOptions = new List<SelectListItem>();
|
PageSizeOptions = new List<SelectListItem>();
|
||||||
Products = new List<ProductDetailsModel>();
|
Products = new List<ProductOverviewModel>();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,13 @@ public partial record ProductOverviewModel : BaseNopEntityModel
|
||||||
PictureModels = new List<PictureModel>();
|
PictureModels = new List<PictureModel>();
|
||||||
ProductSpecificationModel = new ProductSpecificationModel();
|
ProductSpecificationModel = new ProductSpecificationModel();
|
||||||
ReviewOverviewModel = new ProductReviewOverviewModel();
|
ReviewOverviewModel = new ProductReviewOverviewModel();
|
||||||
|
Manufacturers = new List<ManufacturerBriefInfoModel>(); // ADDED - A.
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string ShortDescription { get; set; }
|
public string ShortDescription { get; set; }
|
||||||
public string FullDescription { get; set; }
|
public string FullDescription { get; set; }
|
||||||
|
|
||||||
public string SeName { get; set; }
|
public string SeName { get; set; }
|
||||||
|
|
||||||
public string Sku { get; set; }
|
public string Sku { get; set; }
|
||||||
|
|
@ -33,6 +35,7 @@ public partial record ProductOverviewModel : BaseNopEntityModel
|
||||||
public ProductSpecificationModel ProductSpecificationModel { get; set; }
|
public ProductSpecificationModel ProductSpecificationModel { get; set; }
|
||||||
//price
|
//price
|
||||||
public ProductReviewOverviewModel ReviewOverviewModel { get; set; }
|
public ProductReviewOverviewModel ReviewOverviewModel { get; set; }
|
||||||
|
public IList<ManufacturerBriefInfoModel> Manufacturers { get; set; } // ADDED - A.
|
||||||
|
|
||||||
#region Nested Classes
|
#region Nested Classes
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
@model ProductDetailsModel
|
@model ProductOverviewModel
|
||||||
@using Nop.Core
|
@using Nop.Core
|
||||||
@using Nop.Core.Domain.Catalog
|
@using Nop.Core.Domain.Catalog
|
||||||
@using Nop.Core.Domain.Orders
|
@using Nop.Core.Domain.Orders
|
||||||
@using Nop.Core.Domain.Tax
|
@using Nop.Core.Domain.Tax
|
||||||
|
@using System.Web
|
||||||
@inject CatalogSettings catalogSettings
|
@inject CatalogSettings catalogSettings
|
||||||
@inject IWorkContext workContext
|
@inject IWorkContext workContext
|
||||||
@{
|
@{
|
||||||
|
|
@ -10,14 +11,14 @@
|
||||||
var addtocartlink = "";
|
var addtocartlink = "";
|
||||||
var shoppingCartTypeId = (int)ShoppingCartType.ShoppingCart;
|
var shoppingCartTypeId = (int)ShoppingCartType.ShoppingCart;
|
||||||
var quantity = 1;
|
var quantity = 1;
|
||||||
// if (Model.ProductPrice.ForceRedirectionAfterAddingToCart)
|
if (Model.ProductPrice.ForceRedirectionAfterAddingToCart)
|
||||||
// {
|
{
|
||||||
// addtocartlink = Url.RouteUrl("AddProductToCart-Catalog", new { productId = Model.Id, shoppingCartTypeId = shoppingCartTypeId, quantity = quantity, forceredirection = Model.ProductPrice.ForceRedirectionAfterAddingToCart });
|
addtocartlink = Url.RouteUrl("AddProductToCart-Catalog", new { productId = Model.Id, shoppingCartTypeId = shoppingCartTypeId, quantity = quantity, forceredirection = Model.ProductPrice.ForceRedirectionAfterAddingToCart });
|
||||||
// }
|
}
|
||||||
// else
|
else
|
||||||
// {
|
{
|
||||||
addtocartlink = Url.RouteUrl("AddProductToCart-Catalog", new { productId = Model.Id, shoppingCartTypeId = shoppingCartTypeId, quantity = quantity });
|
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 addtowishlistlink = Url.RouteUrl("AddProductToCart-Catalog", new { productId = Model.Id, shoppingCartTypeId = (int)ShoppingCartType.Wishlist, quantity = quantity });
|
||||||
var addtocomparelink = Url.RouteUrl("AddProductToCompare", new { productId = Model.Id });
|
var addtocomparelink = Url.RouteUrl("AddProductToCompare", new { productId = Model.Id });
|
||||||
|
|
@ -60,10 +61,10 @@
|
||||||
<h2 class="product-title">
|
<h2 class="product-title">
|
||||||
<a href="@(Url.RouteUrl<Product>(new {SeName = Model.SeName }))">@Model.Name</a>
|
<a href="@(Url.RouteUrl<Product>(new {SeName = Model.SeName }))">@Model.Name</a>
|
||||||
</h2>
|
</h2>
|
||||||
@if(Model.ProductManufacturers.Count > 0)
|
@if (Model.Manufacturers.Count > 0) // ADDED - A.
|
||||||
{
|
{
|
||||||
string manufacturers = "";
|
string manufacturers = "";
|
||||||
foreach(var manu in Model.ProductManufacturers)
|
foreach(var manu in Model.Manufacturers)
|
||||||
{
|
{
|
||||||
manufacturers = manufacturers + manu.Name + ";";
|
manufacturers = manufacturers + manu.Name + ";";
|
||||||
}
|
}
|
||||||
|
|
@ -75,14 +76,14 @@
|
||||||
@Model.Sku
|
@Model.Sku
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@if (Model.ProductReviewOverview.AllowCustomerReviews)
|
@if (Model.ReviewOverviewModel.AllowCustomerReviews)
|
||||||
{
|
{
|
||||||
var ratingPercent = 0;
|
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 class="rating">
|
||||||
<div style="width: @(ratingPercent)%">
|
<div style="width: @(ratingPercent)%">
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -90,7 +91,7 @@
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
<div class="description" @(catalogSettings.ShowShortDescriptionOnCatalogPages ? "" : "data-short-description=none")>
|
<div class="description" @(catalogSettings.ShowShortDescriptionOnCatalogPages ? "" : "data-short-description=none")>
|
||||||
@Html.Raw(Model.ShortDescription)
|
@Html.Raw(HttpUtility.HtmlDecode(Model.ShortDescription))
|
||||||
</div>
|
</div>
|
||||||
<div class="add-info">
|
<div class="add-info">
|
||||||
@await Component.InvokeAsync(typeof(WidgetViewComponent), new { widgetZone = PublicWidgetZones.ProductBoxAddinfoBefore, additionalData = Model })
|
@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 })
|
@await Component.InvokeAsync(typeof(WidgetViewComponent), new { widgetZone = PublicWidgetZones.ProductBoxAddinfoMiddle, additionalData = Model })
|
||||||
<div class="buttons">
|
<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>*@
|
@*<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;
|
var addToCartText = T("ShoppingCart.AddToCart").Text;
|
||||||
if (Model.ProductPrice.IsRental)
|
if (Model.ProductPrice.IsRental)
|
||||||
{
|
{
|
||||||
addToCartText = T("ShoppingCart.Rent").Text;
|
addToCartText = T("ShoppingCart.Rent").Text;
|
||||||
}
|
}
|
||||||
if (Model.AddToCart.AvailableForPreOrder)
|
if (Model.ProductPrice.AvailableForPreOrder)
|
||||||
{
|
{
|
||||||
addToCartText = T("ShoppingCart.PreOrder").Text;
|
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>
|
<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>
|
<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>
|
<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