Skip to content

Commit 0280836

Browse files
committed
Merge branch '4.90-bug-fixes' into develop
# Conflicts: # src/Presentation/Nop.Web/Controllers/ShoppingCartController.cs
2 parents bc082f2 + 958f5b9 commit 0280836

File tree

2 files changed

+10
-42
lines changed

2 files changed

+10
-42
lines changed

src/Presentation/Nop.Web/Controllers/CatalogController.cs

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Microsoft.AspNetCore.Mvc;
22
using Nop.Core;
33
using Nop.Core.Domain.Catalog;
4-
using Nop.Core.Domain.Customers;
54
using Nop.Core.Domain.FilterLevels;
65
using Nop.Core.Domain.Media;
76
using Nop.Core.Domain.Vendors;
@@ -119,12 +118,6 @@ public virtual async Task<IActionResult> Category(int categoryId, CatalogProduct
119118

120119
var store = await _storeContext.GetCurrentStoreAsync();
121120

122-
//'Continue shopping' URL
123-
await _genericAttributeService.SaveAttributeAsync(await _workContext.GetCurrentCustomerAsync(),
124-
NopCustomerDefaults.LastContinueShoppingPageAttribute,
125-
_webHelper.GetThisPageUrl(false),
126-
store.Id);
127-
128121
//display "edit" (manage) link
129122
if (await _permissionService.AuthorizeAsync(StandardPermission.Security.ACCESS_ADMIN_PANEL) && await _permissionService.AuthorizeAsync(StandardPermission.Catalog.CATEGORIES_VIEW))
130123
DisplayEditLink(Url.Action("Edit", "Category", new { id = category.Id, area = AreaNames.ADMIN }));
@@ -165,14 +158,6 @@ public virtual async Task<IActionResult> Manufacturer(int manufacturerId, Catalo
165158
if (!await CheckManufacturerAvailabilityAsync(manufacturer))
166159
return InvokeHttp404();
167160

168-
var store = await _storeContext.GetCurrentStoreAsync();
169-
170-
//'Continue shopping' URL
171-
await _genericAttributeService.SaveAttributeAsync(await _workContext.GetCurrentCustomerAsync(),
172-
NopCustomerDefaults.LastContinueShoppingPageAttribute,
173-
_webHelper.GetThisPageUrl(false),
174-
store.Id);
175-
176161
//display "edit" (manage) link
177162
if (await _permissionService.AuthorizeAsync(StandardPermission.Security.ACCESS_ADMIN_PANEL) && await _permissionService.AuthorizeAsync(StandardPermission.Catalog.MANUFACTURER_VIEW))
178163
DisplayEditLink(Url.Action("Edit", "Manufacturer", new { id = manufacturer.Id, area = AreaNames.ADMIN }));
@@ -221,14 +206,6 @@ public virtual async Task<IActionResult> Vendor(int vendorId, CatalogProductsCom
221206
if (!await CheckVendorAvailabilityAsync(vendor))
222207
return InvokeHttp404();
223208

224-
var store = await _storeContext.GetCurrentStoreAsync();
225-
226-
//'Continue shopping' URL
227-
await _genericAttributeService.SaveAttributeAsync(await _workContext.GetCurrentCustomerAsync(),
228-
NopCustomerDefaults.LastContinueShoppingPageAttribute,
229-
_webHelper.GetThisPageUrl(false),
230-
store.Id);
231-
232209
//display "edit" (manage) link
233210
if (await _permissionService.AuthorizeAsync(StandardPermission.Security.ACCESS_ADMIN_PANEL) && await _permissionService.AuthorizeAsync(StandardPermission.Customers.VENDORS_VIEW))
234211
DisplayEditLink(Url.Action("Edit", "Vendor", new { id = vendor.Id, area = AreaNames.ADMIN }));
@@ -380,14 +357,6 @@ public virtual async Task<IActionResult> NewProductsRss()
380357

381358
public virtual async Task<IActionResult> Search(SearchModel model, CatalogProductsCommand command)
382359
{
383-
var store = await _storeContext.GetCurrentStoreAsync();
384-
385-
//'Continue shopping' URL
386-
await _genericAttributeService.SaveAttributeAsync(await _workContext.GetCurrentCustomerAsync(),
387-
NopCustomerDefaults.LastContinueShoppingPageAttribute,
388-
_webHelper.GetThisPageUrl(true),
389-
store.Id);
390-
391360
if (model == null)
392361
model = new SearchModel();
393362

@@ -528,14 +497,6 @@ public virtual async Task<IActionResult> SearchByFilterLevelValues(SearchFilterL
528497
if (!_filterLevelSettings.FilterLevelEnabled)
529498
return RedirectToRoute(NopRouteNames.General.HOMEPAGE);
530499

531-
var store = await _storeContext.GetCurrentStoreAsync();
532-
533-
//'Continue shopping' URL
534-
await _genericAttributeService.SaveAttributeAsync(await _workContext.GetCurrentCustomerAsync(),
535-
NopCustomerDefaults.LastContinueShoppingPageAttribute,
536-
_webHelper.GetThisPageUrl(true),
537-
store.Id);
538-
539500
if (model == null)
540501
model = new SearchFilterLevelValueModel();
541502

src/Presentation/Nop.Web/Controllers/ShoppingCartController.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -596,15 +596,24 @@ public virtual async Task<IActionResult> AddProductToCart_Catalog(int productId,
596596

597597
var product = await _productService.GetProductByIdAsync(productId);
598598
if (product == null)
599-
//no product found
600599
{
600+
//no product found
601601
return Json(new
602602
{
603603
success = false,
604604
message = "No product found with the specified ID"
605605
});
606606
}
607607

608+
var customer = await _workContext.GetCurrentCustomerAsync();
609+
var store = await _storeContext.GetCurrentStoreAsync();
610+
var referrerPageUrl = _webHelper.GetUrlReferrer();
611+
//'Continue shopping' URL
612+
await _genericAttributeService.SaveAttributeAsync(customer,
613+
NopCustomerDefaults.LastContinueShoppingPageAttribute,
614+
referrerPageUrl,
615+
store.Id);
616+
608617
var redirectUrl = await _nopUrlHelper.RouteGenericUrlAsync(product);
609618

610619
//we can add only simple products
@@ -664,8 +673,6 @@ public virtual async Task<IActionResult> AddProductToCart_Catalog(int productId,
664673

665674
//get standard warnings without attribute validations
666675
//first, try to find existing shopping cart item
667-
var customer = await _workContext.GetCurrentCustomerAsync();
668-
var store = await _storeContext.GetCurrentStoreAsync();
669676
var cart = await _shoppingCartService.GetShoppingCartAsync(customer, cartType, store.Id);
670677
var shoppingCartItem = await _shoppingCartService.FindShoppingCartItemInTheCartAsync(cart, cartType, product);
671678
//if we already have the same product in the cart, then use the total quantity to validate

0 commit comments

Comments
 (0)