Magento 1.6 Controllers – Shared Controller for Frontend and Backend Actions

controllersmagento-1.6

I am using same controller for front-end and back-end action, everything works fine except setting global messages when redirect back to desired admin page.

I have used standard admin session handler to set messages for admin actions:

$notifierObject = Mage::getSingleton('adminhtml/session');

PS:

  1. Controller being called is of front-end type.

  2. Redirected admin page is an order view page.

Thanks in advance.

EDIT

Customer action : my.testdomain.com/modulename/controllerfrontname/action1 is called when form is submitted.

Similar form is there in admin sales order view page.
Admin form submit action : my.testdomain.com/modulename/controllerfrontname/action1 , as you can see the same action is called.

frontName of admin and frontend routers is the same – modulename.(But I guess, this is not causing any problem)

I am successfully getting redirected back to admin sales order view page, but without any global messages that I have set in $notifierObject of admin session. That's the only problem.

Best Answer

your question is somehow unclear, but I can give you one hint.
Don't use the same controller for frontend and backend.
you should have 2 of them because they serve 2 different purposes.
If you don't want to duplicate the code, out the common methods in a helper and call them in the different controllers.