I am willing to override the "_RentalInfo.cshtml" and "_AddToCart.cshtml" pages from my Plugin. For this, I created the custom View Engine and provided the path to the files into "PartialViewLocationFormats, ViewLocationFormats". //CustomViewEngine Class
public class CustomViewEngine : ThemeableRazorViewEngine
{
public CustomViewEngine()
{
PartialViewLocationFormats = new[] { "~/Plugins/Misc.Rental/Views/Product/{0}.cshtml" };
ViewLocationFormats = new[] { "~/Plugins/Misc.Rental/Views/Product/{0}.cshtml" };
}
}
Then, I created the RouteProvider.cs file within Plugin and added my "CustomViewEngine" within view engine list. I also set the priority of my route provider as highest.
//RouteProvider
public partial class RouteProvider : IRouteProvider
{
#region Fields
public int Priority
{
get
{
return int.MaxValue;
}
}
#endregion
#region Methods
public void RegisterRoutes(RouteCollection routes)
{
ViewEngines.Engines.Add(new CustomViewEngine());
}
#endregion
}
Lastly, as per the path mentioned in my "CustomViewEngine", I have created the "_RentalInfo.cshtml" and "_AddToCart.cshtml" pages beneath "Views" folder within my plugin.
But, then too default NopCommerce default partial view is only being displayed. Can anyone review my code and let me know, what I have performed wrong or missing to override the partial views.