franklinfs Posted December 27, 2013 Share Posted December 27, 2013 Hai, For a module development, i need to add some code into AdminOrdersController.php file. But i dont want to add the code into above core file. how can i add the code. Can i use override method for this? How can i use override method. Just i want to add the following code in the function "public function initToolbar()" $orderid = $_GET['id_order']; if ($orderid!='') $this->toolbar_btn['test'] = array( 'href' => '#', 'desc' => $this->l('Test Button') ); Link to comment Share on other sites More sharing options...
NemoPS Posted December 27, 2013 Share Posted December 27, 2013 This might help you: http://nemops.com/extending-prestashop-objects/ Basically, you have to create a subfolder in your module's folder named override Inside this, the structure controllers/admin and the file named AdminOrdersController inside it Link to comment Share on other sites More sharing options...
franklinfs Posted December 28, 2013 Author Share Posted December 28, 2013 Hai Nemo, Yes. I used the override method. I refer the tutorial and doing the function override method and solved the issue. But i have one doubt about this method. Is this method is best practice? Link to comment Share on other sites More sharing options...
NemoPS Posted December 28, 2013 Share Posted December 28, 2013 Yes, as far as I know, because overriding methods will allow you to keep modifications even after upgrading your store Link to comment Share on other sites More sharing options...
franklinfs Posted December 30, 2013 Author Share Posted December 30, 2013 Okay Thanks! Link to comment Share on other sites More sharing options...
webdeli Posted April 4, 2014 Share Posted April 4, 2014 (edited) Having read the post... Is there a way to add the table alteration into code - rather than just using something like phpMyAdmin to hand alter the table first in step 1? If you have code sample / link to another post or URL of some documentation covering this for module development - i'd really appreciate it. Edited April 4, 2014 by webdeli (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted April 5, 2014 Share Posted April 5, 2014 You can create an alteration function within the module, and call it inside the install() method so it will add the column once the module is installed. Don't forget to remove it withing uninstall() then! Link to comment Share on other sites More sharing options...
Recommended Posts