Mukesh Ravi Posted March 19, 2014 Share Posted March 19, 2014 Hi All, I am using Prestashop 1.5.6 I want add a new custom action (say "new action") in render action list. I reached to admincontroller but don't know how to do this? For more clarification I am attaching a screenshot. Please help me. Thanks in Advance...! Link to comment Share on other sites More sharing options...
Mukesh Ravi Posted March 19, 2014 Author Share Posted March 19, 2014 Anyone please help... Link to comment Share on other sites More sharing options...
Mukesh Ravi Posted March 21, 2014 Author Share Posted March 21, 2014 Is there no body to help on this topic Link to comment Share on other sites More sharing options...
Enrique Gómez Posted March 21, 2014 Share Posted March 21, 2014 In AdminProductsController line 2294 you can add a row action (test for example) public function renderList() { $this->addRowAction('edit'); $this->addRowAction('duplicate'); $this->addRowAction('delete'); $this->addRowAction('test'); return parent::renderList(); } Then in the same controller (or in the HelperList) you need to define the displayTestLink. For example this one is copy pasted from the displayEditLink in the HelperList, and changed only the title, from Edit to Test and the path to find the tpl (since we are in the controller) public function displayTestLink($token = null, $id, $name = null) { $tpl = $this->createTemplate('helpers/list/list_action_edit.tpl'); if (!array_key_exists('Test', self::$cache_lang)) self::$cache_lang['Test'] = $this->l('Test', 'Helper'); $tpl->assign(array( 'href' => $this->currentIndex.'&'.$this->identifier.'='.$id.'&update'.$this->table.'&token='.($token != null ? $token : $this->token), 'action' => self::$cache_lang['Test'], 'id' => $id )); return $tpl->fetch(); } But you get the idea, you generate the html for each button dinamicaly, the tpl is very simple: <a href="{$href}" class="edit" title="{$action}"> <img src="../img/admin/edit.gif" alt="{$action}" /> </a> 5 Link to comment Share on other sites More sharing options...
Mukesh Ravi Posted April 2, 2014 Author Share Posted April 2, 2014 (edited) Thanks Enrique Gomez, Its working... But I need to override these file in our module. So Please Suggest me what I do. I am waiting for your quick response. Thanks Edited April 3, 2014 by [email protected] (see edit history) Link to comment Share on other sites More sharing options...
Enrique Gómez Posted April 3, 2014 Share Posted April 3, 2014 You can have a look at http://doc.prestashop.com/display/PS15/Overriding+default+behaviors#Overridingdefaultbehaviors-Overridingacontroller you can put your AdminProductsController under override/controllers/admin, override the public function renderList() and add your displayXXXLink method don't forget to delete cache/class_index.php if you do it manually. Link to comment Share on other sites More sharing options...
gajofe Posted May 5, 2015 Share Posted May 5, 2015 and the action trigger, how to associate the test link to test action.... ... in the controller 1 Link to comment Share on other sites More sharing options...
Nyah Posted June 4, 2015 Share Posted June 4, 2015 I want to associate the link to a new page but i don't know how 1 Link to comment Share on other sites More sharing options...
cikcak Posted September 21, 2015 Share Posted September 21, 2015 You can have a look at http://doc.prestashop.com/display/PS15/Overriding+default+behaviors#Overridingdefaultbehaviors-Overridingacontroller you can put your AdminProductsController under override/controllers/admin, override the public function renderList() and add your displayXXXLink method don't forget to delete cache/class_index.php if you do it manually. Hey man, is it possible to override controller and add custom row action or order products? I can`t even find where should I do it. In AdminProduct or AdminOrders controller? Thanks for any help! Link to comment Share on other sites More sharing options...
agung_mp Posted September 25, 2015 Share Posted September 25, 2015 what about overriding 'delete' action, i want to add custom function for 'delete' action in my module. Link to comment Share on other sites More sharing options...
Ali Samie Posted January 9, 2023 Share Posted January 9, 2023 On 3/21/2014 at 12:40 PM, Enrique Gómez said: In AdminProductsController line 2294 you can add a row action (test for example) public function renderList() { $this->addRowAction('edit'); $this->addRowAction('duplicate'); $this->addRowAction('delete'); $this->addRowAction('test'); return parent::renderList(); } Then in the same controller (or in the HelperList) you need to define the displayTestLink. For example this one is copy pasted from the displayEditLink in the HelperList, and changed only the title, from Edit to Test and the path to find the tpl (since we are in the controller) public function displayTestLink($token = null, $id, $name = null) { $tpl = $this->createTemplate('helpers/list/list_action_edit.tpl'); if (!array_key_exists('Test', self::$cache_lang)) self::$cache_lang['Test'] = $this->l('Test', 'Helper'); $tpl->assign(array( 'href' => $this->currentIndex.'&'.$this->identifier.'='.$id.'&update'.$this->table.'&token='.($token != null ? $token : $this->token), 'action' => self::$cache_lang['Test'], 'id' => $id )); return $tpl->fetch(); } But you get the idea, you generate the html for each button dinamicaly, the tpl is very simple: <a href="{$href}" class="edit" title="{$action}"> <img src="../img/admin/edit.gif" alt="{$action}" /> </a> Thanks a lot I used your guide like this to create a custom button which is linked to customer page Although I wanted to have the customer ID to be clickable but this is a good workaround too public function displayViewCustomerLink($token = null, $id, $name = null) { $tpl = $this->createTemplate('helpers/list/list_action_view.tpl'); $tpl->assign(array( 'href' => Context::getContext()->link->getAdminLink( 'AdminCustomers', true, [ 'customerId' => $id, 'viewcustomer' => true, ] ), 'action' => 'View Customer', 'id' => $id )); return $tpl->fetch(); } BEFORE AFTER 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