I had a couple scenarios where I wanted to override some Nop admins views and was experimenting with the best way to do it. I also saw some questions out there on various forums asking how to do this. I thought I'd compile my findings into a blog post that walks you through how to override Admin Views and Partial Views with ease.
I am trying to override an admin partial view(Nop.Web\Administration\Views\Order\_OrderDetails.Shipping.cshtml used in the Nop.Web\Administration\Views\Order\Edit.cshtml) in a Shipping Computation method plugin. I followed the guidelines in your blog post but couldn't quite manage to accomplish the task.
I created a CustomViewEngine which inherits from RazorViewEngine, added the partial view search locations. Next I inserted the CustomViewEngine before the other View engines in my RouteCoinfig class. Since I am overriding partial view, I don't need a controller and route to it. So finally I added my partial view to the search location in my plugin.
Unfortunately the effect was that Nop was still using its own admin views. Only when I rename the original partial view, Nop loads the one from the plugin. When I rename it as well, I can see the search locations in the browser with my plugin's location at the front:
The partial view '_OrderDetails.Shipping' was not found or no view engine supports the searched locations. The following locations were searched: ~/Plugins/Shipping.Rapido/Views/_OrderDetails.Shipping.cshtml ~/Administration/Views/Shared/_OrderDetails.Shipping.cshtml ~/Administration/Views/Order/_OrderDetails.Shipping.cshtml ...
It looks as if I am missing something. Maybe after all I should override the parent admin view as well, add an action for it and a controller route.
I am trying to override an admin partial view(Nop.Web\Administration\Views\Order\_OrderDetails.Shipping.cshtml used in the Nop.Web\Administration\Views\Order\Edit.cshtml) in a Shipping Computation method plugin. I followed the guidelines in your blog post but couldn't quite manage to accomplish the task.
I created a CustomViewEngine which inherits from RazorViewEngine, added the partial view search locations. Next I inserted the CustomViewEngine before the other View engines in my RouteCoinfig class. Since I am overriding partial view, I don't need a controller and route to it. So finally I added my partial view to the search location in my plugin.
Unfortunately the effect was that Nop was still using its own admin views. Only when I rename the original partial view, Nop loads the one from the plugin. When I rename it as well, I can see the search locations in the browser with my plugin's location at the front:
The partial view '_OrderDetails.Shipping' was not found or no view engine supports the searched locations. The following locations were searched: ~/Plugins/Shipping.Rapido/Views/_OrderDetails.Shipping.cshtml ~/Administration/Views/Shared/_OrderDetails.Shipping.cshtml ~/Administration/Views/Order/_OrderDetails.Shipping.cshtml ...
It looks as if I am missing something. Maybe after all I should override the parent admin view as well, add an action for it and a controller route.
Check the property of the file. Make copy always for Copy to output directories.
No this is not the problem, the overridden partial view is copied to the output directory as expected, but the view engine uses it only if the original one is missing.
No it is not working.I set copy always and the path is exactly as you told but it shows error and the message is "The partial view was not found or no view engine supports the searched locations."
partial view cant loaded on nopcommerce 3.8 on plugin side.I write this on controller side. return PartialView("~/Plugins/Twigoh.Sellers/Views/Dashboard/vendorProfile.cshtml", model); and view side @Html.Partial("vendorProfile"); Action name and view almost same.
I had a couple scenarios where I wanted to override some Nop admins views and was experimenting with the best way to do it. I also saw some questions out there on various forums asking how to do this. I thought I'd compile my findings into a blog post that walks you through how to override Admin Views and Partial Views with ease.