Jump to content

Admin controller


annaarun

Recommended Posts

Hello,

 

        Understood how to add new action to the controller :).

 

        Requirement :

 

                prestashop/admin0148eaqno/index.php?fc=module&module=mymodule&controller=AdminDisplayadmin&test

 

                on taking this url in browser I have to execute code in test action

 

                >> Module      = > "mymodule"

 

                >> Controller   => "AdminDisplayadmin"

 

                >> New action => "test"

 

        I did it as follow :

 

        1) Added the initProcess function in my controller to define action as follow :

 

              public function initProcess() //Retrieve GET and POST value and translate them to actions
              {
                    parent::initProcess();
                    if($_GET['test'])
                    {
                       $this->action = 'test';
                    }
              }

 

         2) Defined action by prefixing process as follow :

 

               public function processTest()
               {
                    .......
               }

 

        Its working as expected.

Link to comment
Share on other sites

Hello,

 

        For adding new action you don't have to add the initProcess() function in your controller. Just need to make a  change

 

in your url.

 

Instead of prestashop/admin0148eaqno/index.php?fc=module&module=mymodule&controller=AdminDisplayadmin&test

 

Use prestashop/admin0148eaqno/index.php?fc=module&module=mymodule&controller=AdminDisplayadmin&action=test

 

Then add the processTest() function. It will be invoked. Please refer the initProcess function in AdminController.php in

 

classes/controller folder.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...