Plugin doesn't override admin controller

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
9 years ago
Does anybody facing this issues? I am trying to override admin controller with plugin, but then sometime the system doesn't override it, but after few restart it will work again. Is there any way to load it after restart application at one time only?
9 years ago
etws14 wrote:
Does anybody facing this issues? I am trying to override admin controller with plugin, but then sometime the system doesn't override it, but after few restart it will work again. Is there any way to load it after restart application at one time only?


Any sample codes of how you are wiring things up? Without sample codes we can't comment much... :)
9 years ago
wooncherk wrote:
Does anybody facing this issues? I am trying to override admin controller with plugin, but then sometime the system doesn't override it, but after few restart it will work again. Is there any way to load it after restart application at one time only?

Any sample codes of how you are wiring things up? Without sample codes we can't comment much... :)



using Nop.Core.Infrastructure;
using Nop.Core.Plugins;
using System.Web.Mvc;
namespace Misc.ExportCustomer
{
    public class AdminAreaRegistration : AreaRegistration
    {
        public override string AreaName
        {
            get { return "Admin"; }
        }

        public override void RegisterArea(AreaRegistrationContext context)
        {
            var pluginFinder = EngineContext.Current.Resolve<IPluginFinder>();

            if (pluginFinder != null)
            {
                var pluginDescriptor = pluginFinder.GetPluginDescriptorBySystemName("Misc.ExportCustomer");
                if (pluginDescriptor != null)
                {
                    context.MapRoute(
                        "export_customer",
                        "Admin/Customer/ExportExcelAll",
                        new { controller = "CustomCustomer", action = "ExportExcelAll", area = "Admin" },
                        new[] { "Misc.ExportCustomer.Controllers" });
                }
            }
        }
    }
}


this is how I register it to override the ExportExcelAll action. Actually it is working, but sometime when I restart the application to load the update to the latest library files. It doesn't override the ExportExcelAll action, to resolve it I need to restart the application again, sometime few times.

What I concern is, as myself know that the library files is loaded properly, but customer don't. So I want to make sure the action is overrided 100% at all time.
9 years ago
Why not try this instead? [url=Overriding (Intercepting) nopCommerce Controllers and Actions]http://www.pronopcommerce.com/overriding-intercepting-nopcommerce-controllers-and-actions[/url]
9 years ago
wooncherk wrote:
Why not try this instead? [url=Overriding (Intercepting) nopCommerce Controllers and Actions]http://www.pronopcommerce.com/overriding-intercepting-nopcommerce-controllers-and-actions[/url]


okay, I will try it after complete other tasks
9 years ago
wooncherk wrote:
Why not try this instead? [url=Overriding (Intercepting) nopCommerce Controllers and Actions]http://www.pronopcommerce.com/overriding-intercepting-nopcommerce-controllers-and-actions[/url]


I have tried it, but seem like I need to redirect to the path that I customize it. Is there anyway, I just want to keep the url but the controller and action is the one I've created?
9 years ago
etws14 wrote:
Why not try this instead? [url=Overriding (Intercepting) nopCommerce Controllers and Actions]http://www.pronopcommerce.com/overriding-intercepting-nopcommerce-controllers-and-actions[/url]

I have tried it, but seem like I need to redirect to the path that I customize it. Is there anyway, I just want to keep the url but the controller and action is the one I've created?


I don't get "but seem like I need to redirect to the path that I customize it". Can you explain again? :)
9 years ago
wooncherk wrote:
Why not try this instead? [url=Overriding (Intercepting) nopCommerce Controllers and Actions]http://www.pronopcommerce.com/overriding-intercepting-nopcommerce-controllers-and-actions[/url]

I have tried it, but seem like I need to redirect to the path that I customize it. Is there anyway, I just want to keep the url but the controller and action is the one I've created?

I don't get "but seem like I need to redirect to the path that I customize it". Can you explain again? :)


okay just get the example of StoreClosedAttribute, the system redirect to StoreClosed page and the url path is change to /StoreClosed. But what I want it is the url path didn't change. For example, /customer/info. Suppose the ActionName Info in CustomerController is executing, but I want it to be CustomCustomerController.

I've successfully make it work by creating RouteProvider for frontend. For backend, I've created an AreaRegistration to overlap it and it's work too, but sometimes doesn't work.
9 years ago
etws14 wrote:
Why not try this instead? [url=Overriding (Intercepting) nopCommerce Controllers and Actions]http://www.pronopcommerce.com/overriding-intercepting-nopcommerce-controllers-and-actions[/url]

I have tried it, but seem like I need to redirect to the path that I customize it. Is there anyway, I just want to keep the url but the controller and action is the one I've created?

I don't get "but seem like I need to redirect to the path that I customize it". Can you explain again? :)

okay just get the example of StoreClosedAttribute, the system redirect to StoreClosed page and the url path is change to /StoreClosed. But what I want it is the url path didn't change. For example, /customer/info. Suppose the ActionName Info in CustomerController is executing, but I want it to be CustomCustomerController.

I've successfully make it work by creating RouteProvider for frontend. For backend, I've created an AreaRegistration to overlap it and it's work too, but sometimes doesn't work.


The line that make it redirect is

if (storeInformationSettings.StoreClosedAllowForAdmins && EngineContext.Current.Resolve<IWorkContext>().CurrentCustomer.IsAdmin())
{
    //do nothing - allow admin access
}
else
{
    var storeClosedUrl = new UrlHelper(filterContext.RequestContext).RouteUrl("StoreClosed");
    filterContext.Result = new RedirectResult(storeClosedUrl); // <-- this line makes it redirect
}


Remove it and it'll stay with the same Action. :)
9 years ago
wooncherk wrote:
Why not try this instead? [url=Overriding (Intercepting) nopCommerce Controllers and Actions]http://www.pronopcommerce.com/overriding-intercepting-nopcommerce-controllers-and-actions[/url]

I have tried it, but seem like I need to redirect to the path that I customize it. Is there anyway, I just want to keep the url but the controller and action is the one I've created?

I don't get "but seem like I need to redirect to the path that I customize it". Can you explain again? :)

okay just get the example of StoreClosedAttribute, the system redirect to StoreClosed page and the url path is change to /StoreClosed. But what I want it is the url path didn't change. For example, /customer/info. Suppose the ActionName Info in CustomerController is executing, but I want it to be CustomCustomerController.

I've successfully make it work by creating RouteProvider for frontend. For backend, I've created an AreaRegistration to overlap it and it's work too, but sometimes doesn't work.

The line that make it redirect is

if (storeInformationSettings.StoreClosedAllowForAdmins && EngineContext.Current.Resolve<IWorkContext>().CurrentCustomer.IsAdmin())
{
    //do nothing - allow admin access
}
else
{
    var storeClosedUrl = new UrlHelper(filterContext.RequestContext).RouteUrl("StoreClosed");
    filterContext.Result = new RedirectResult(storeClosedUrl); // <-- this line makes it redirect
}


Remove it and it'll stay with the same Action. :)


But I want the system fire the custom controller and action, without changing the uri
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.