annaarun Posted October 18, 2016 Share Posted October 18, 2016 How to add new action in admin controller? Link to comment Share on other sites More sharing options...
annaarun Posted October 20, 2016 Author Share Posted October 20, 2016 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 More sharing options...
annaarun Posted October 27, 2016 Author Share Posted October 27, 2016 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now