Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Minor improvements for Quick View - Get related products get from Controller (move away from Component)

supporta32a7b882740
diff --git a/src/Web/Grand.Web/Controllers/ProductController.cs b/src/Web/Grand.Web/Controllers/ProductController.cs
index d47362efb..5dd171e39 100644
--- a/src/Web/Grand.Web/Controllers/ProductController.cs
+++ b/src/Web/Grand.Web/Controllers/ProductController.cs
@@ -452,6 +452,29 @@ namespace Grand.Web.Controllers
#endregion
+ #region Related products
+
+ public virtual async Task<IActionResult> RelatedProducts(string productId, int? productThumbPictureSize)
+ {
+ var productIds = (await _productService.GetProductById(productId)).RelatedProducts.OrderBy(x => x.DisplayOrder).Select(x => x.ProductId2).ToArray();
+
+ //load products
+ var products = await _productService.GetProductsByIds(productIds);
+
+ var model = await _mediator.Send(new GetProductOverview() {
+ PreparePictureModel = true,
+ PreparePriceModel = true,
+ PrepareSpecificationAttributes = _catalogSettings.ShowSpecAttributeOnCatalogPages,
+ ProductThumbPictureSize = productThumbPictureSize,
+ Products = products
+ });
+
+ return View(model);
+ }
+
+ #endregion
+
+
#region Recently added products
public virtual async Task<IActionResult> NewProducts()
diff --git a/src/Web/Grand.Web/wwwroot/theme/script/app.js b/src/Web/Grand.Web/wwwroot/theme/script/app.js
index bf645c710..e1312c3de 100644
--- a/src/Web/Grand.Web/wwwroot/theme/script/app.js
+++ b/src/Web/Grand.Web/wwwroot/theme/script/app.js
@@ -493,10 +493,9 @@ var vm = new Vue({
getLinkedProductsQV: function (id) {
var data = { productId: id };
axios({
- url: '/Component/Index',
- method: 'post',
- params: { "name": "RelatedProducts" },
- data: JSON.stringify(data),
+ url: '/Product/RelatedProducts',
+ method: 'get',
+ params: { "productId": id },
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',