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

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 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.
4 years ago
did you get the solution.if yes could you please share
4 years 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.
4 years ago
Also you can use admin widgets for add new functionality in admin area.
4 years 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)
        {
4 years 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?
4 years ago
Is it still calling the original controller/method?
4 years 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
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.