Override /Admin/Order/List for downloading print pdf invoices (all found)

2 years ago
Hello.
I want to override a rout for downloading print pdf invoices (all found).

I do it for selected items from : Admin/Order/PdfInvoiceSelected/
and also for every single order from : Admin/Order/PdfInvoice/
but I can't override for add found in list of orders.



using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;
using Nop.Web.Framework.Mvc.Routing;

namespace Nop.Plugin.Widgets.SerialNumber.Infrastructure
{
    public partial class RouteProvider : IRouteProvider
    {
        public void RegisterRoutes(IRouteBuilder routeBuilder)
        {
            routeBuilder.MapRoute("Widgets.SerialNumber.PdfInvoice", "Admin/Order/PdfInvoice/",
            new { controller = "Pdf", action = "PdfInvoice" });

            /*routeBuilder.MapRoute("Widgets.SerialNumber.PdfInvoiceAll", "Admin/Order/List/",
                new { controller = "Pdf", action = "PdfInvoiceAll" },
                new { FormValueRequiredAttribute = "pdf-invoice-all" , HttpPostAttribute = "POST"});*/


            routeBuilder.MapRoute("Widgets.SerialNumber.PdfInvoiceSelected", "Admin/Order/PdfInvoiceSelected/",
                new { controller = "Pdf", action = "PdfInvoiceSelected" });
        }
        public int Priority
        {
            get
            {
                return 100;
            }
        }
    }
}


I comment the which part that doesn't work.

Thanks for your helps.
11 months ago
did you get the solution.if yes could you please share
11 months ago
Mtiwana wrote:
did you get the solution.if yes could you please share


which version of nopCommerce you using?
if nopCommerce 4.20, then you can direct override action method.
11 months ago
Also you can use admin widgets for add new functionality in admin area.
11 months ago
i am working in 4.2
I added new button in Button widget in Order List

In plugin i added new Controller
ExportController that inherit from OrderController

in Route i defined like as follow
  routeBuilder.MapRoute("Export", "Admin/Order/List",
                new { controller = "Export", action = "List" });


in view i add new button
   <button type="submit" name="exportmxl-all">
               New Button
            </button>

in exportController try to call following method its not calling

  [HttpPost, ActionName("List")]
        [FormValueRequired("exportmxl-all")]
        public IActionResult ExportMxlAll(OrderSearchModel model)
        {
11 months ago
Hi Mtiwana,
Code seems fine.

Can you let me know what issue you now facing?
Getting any error or direct call on List action method?
11 months ago
Is it still calling the original controller/method?
7 months ago
I am dealing with the same problem.
I see that the problem is with "FormValueRequired", it doesn't work in the plugin.
If I find the solution I will share it

Nop V4.2