So I tried to upgrade the following plugin (3.90) to work with 4.20
https://www.nopcommerce.com/p/2254/multi-currency-plugin.aspx
But it's failing on these lines:
public ActionResult ProductPriceList(DataSourceRequest command, int productId)
{
var product = _productService.GetProductById(productId);
if (product == null)
throw new ArgumentException("No product found with the specified id");
//a vendor should have access only to his products
if (_workContext.CurrentVendor != null && product.VendorId != _workContext.CurrentVendor.Id)
return Content("This is not your product");
var priceList = _priceByCountryService.GetPriceListByProductId(productId);
var productPriceList = priceList
.Select(x =>
{
var productPriceModel = new LocationBasedModel.ProductPriceModel
{
Id = x.Id,
CountryId = x.CountryId,
CurrencyId = x.CurrencyId,
Price = x.Price,
Country = _countryService.GetCountryById(x.CountryId).Name,
Currency = _currencyService.GetCurrencyById(x.CurrencyId).CurrencyCode
};
return productPriceModel;
})
.ToList();
var gridModel = new DataSourceResult
{
Data = productPriceList,
Total = productPriceList.Count
};
return Json(gridModel);
}
and also converted code:
public class ProductController : BasePluginController
{
private readonly IHttpContextAccessor _httpContextAccessor;
public int GetProductId()
{
if (ControllerContext == null)
{
ControllerContext context = new ControllerContext(_httpContextAccessor.HttpContext.Request, this);
ControllerContext = context;
}
int productId = Convert.ToInt32(ControllerContext.HttpContext.Request.Headers["id"]);
return productId;
}
}
since ControllerContext doesn't allow 2 parameters
Original code was:
public class ProductController : Controller
{
public int GetProductId()
{
if (ControllerContext == null)
{
ControllerContext context = new ControllerContext(System.Web.HttpContext.Current.Request.RequestContext, this);
ControllerContext = context;
}
int productId = Convert.ToInt32(ControllerContext.RequestContext.RouteData.Values["id"]);
return productId;
}
}
"Controller" seems to be not used in 4.20 anymore and is using BasePluginController, so I don't know if I could change that to be workable for 4.20