acuarelweb Posted June 2, 2015 Share Posted June 2, 2015 (edited) Hi there. I'm trying to override vouchers list page at the backend (http://localhost/admin/index.php?controller=AdminCartRules ) This is for learning purposes cause the goal is to be able to add another column to that listing page with a custom link I've cretaed a AdminCartRulesController.php file and placed it into the /override/controllers/admin/ folder. The file content is as follows: class AdminCartRulesController extends AdminCartRulesControllerCore{ public function __construct(){ $this->bootstrap = true; $this->table = 'cart_rule'; $this->className = 'CartRule'; $this->lang = true; $this->addRowAction('edit'); $this->addRowAction('delete'); $this->_orderWay = 'DESC'; $this->bulk_actions = array( 'delete' => array('text' => $this->l('Delete selected') ,'icon' => 'icon-trash' , 'confirm' => $this->l('Delete selected items?'))); $this->fields_list = array( 'id_cart_rule' => array('title' => $this->l('ID'), 'align' => 'center', 'class' => 'fixed-width-xs'), 'name' => array('title' => $this->l('Name')), 'code' => array('title' => $this->l('Code'), 'class' => 'fixed-width-sm'), 'date_to' => array('title' => $this->l('Expiration date'), 'type' => 'datetime'), 'active' => array('title' => $this->l('Status'), 'active' => 'status', 'type' => 'bool', 'orderby' => false), ); parent::__construct(); } } as all i want to do is remove columns quantity and priority. But no way. My override is loaded (if i make an error_log call inside the constructor it is triggered ) but it does not work as all the columns are shown (as defined in the parent class) I've also tried to delete class_index.php in cache folder May be i'm missing something here... Any help would be very much apreciated. Edited June 2, 2015 by acuarelweb (see edit history) Link to comment Share on other sites More sharing options...
blackarma Posted June 3, 2015 Share Posted June 3, 2015 (edited) Constructor of your parent is overriding your edits. With that in mind this should(not tested) work: class AdminCartRulesController extends AdminCartRulesControllerCore { public function __construct() { parent::__construct(); unset($this->fields_list['priority']); unset($this->fields_list['quantity']); } } But to remove it from actual visual form field you have to override template files of cart_rules. 1. Create folder 'override/controllers/admin/templates/cart_rules'2. Copy form.tpl and information.tpl from '<admin_folder>/themes/<theme_name>/template/controllers/cart_rules' into folder created in step 1.3. Edit override version of form.tpl file and chage line {include file='controllers/cart_rules/informations.tpl'} to {include file='cart_rules/informations.tpl'} 4. Now edit override version of informations.tpl file to your liking. Edited June 3, 2015 by blackarma (see edit history) Link to comment Share on other sites More sharing options...
acuarelweb Posted June 4, 2015 Author Share Posted June 4, 2015 (edited) Hi blackarma. Thx for the reply Your reply let me face the first part of the problem (removing the unwanted columns). I tried public function __construct(){ parent::__construct(); unset($this->fields_list['priority']); unset($this->fields_list['quantity']); $this->fields_list['reduction_amount'] = array('title' => $this->l('Importe'), 'class' => 'fixed-width-sm', 'currency' =>true, 'type' => 'price', 'color'=>'#cc0000' ); $this->fields_list['reduction_percent'] = array('title' => $this->l('% DCTO'), 'class' => 'fixed-width-sm', 'type' => 'decimal' ); } and it worked. Iv'e now two "beautiful" columns in the listing page. But my goal was to make a custom link in the listing page, lets say, add another column with a link to be able to print the voucher. Your kindly reply was pointing my to modify the edit form for a given voucher, if i'm not wrong :-) After trying to add columns to the listing page (tried the $_select or the $_join properties with no luck :-(, and with your answer in mind and after a few hours googling i've found the addRowAction method and finally i've been able to add another action button with the 'Print' legend on the actions column. So my code looks like: class AdminCartRulesController extends AdminCartRulesControllerCore{ public function __construct(){ parent::__construct(); unset($this->fields_list['priority']); unset($this->fields_list['quantity']); $this->fields_list['reduction_amount'] = array('title' => $this->l('Importe'), 'class' => 'fixed-width-sm', 'currency' =>true, 'type' => 'price', 'color'=>'#cc0000' ); $this->fields_list['reduction_percent'] = array('title' => $this->l('% DCTO'), 'class' => 'fixed-width-sm', 'type' => 'decimal' ); $this->addRowAction('print'); } public function displayPrintLink( $token, $id){ $tpl = $this->createTemplate('helpers/list/list_action_print.tpl'); // My tpl in the override/controllers/admin folder // Could use $tpl->assign(array( $this->context->smarty->assign(array( 'href' => self::$currentIndex.'&token='.$this->token.'&'.$this->identifier.'='.$id.'&print_vale=1&content_only=1', 'action' => $this->l('Imprimir'), 'title'=>"This link should open blank window with my own tpl \nwhere i could show database infos") ); return $tpl->fetch(); } public function renderList(){ return parent::renderList(); } public function initProcess(){ parent::initProcess(); if (Tools::getValue('print_vale')){ $this->display = 'print_voucher'; $this->action = 'print_voucher'; } } public function print_voucher(){ return "this does not work!!"; } } And my override list_action_print.tpl: <a href="{$href|escape:'html':'UTF-8'}" title="{$title|escape:'html':'UTF-8'}" class="print" onclick="window.open('{$href|escape:'html':'UTF-8'}' ); return false;"><i class="icon-print"></i> {$action|escape:'html':'UTF-8'} </a> Now i'm stuck at this point ¿How should i make that link to open a custom blank page where to show the vouchers info, so i can print it? Any help or guidance at this point would be very much apreciated. Regards, Acuarel Edited June 4, 2015 by acuarelweb (see edit history) Link to comment Share on other sites More sharing options...
blackarma Posted June 4, 2015 Share Posted June 4, 2015 (edited) Hey i'm not too much into frontend side, but you could start of by invoking something like //'href' => self::$currentIndex.'&token='.$this->token.'&'.$this->identifier.'='.$id.'&print_vale=1&content_only=1', 'href' => 'javascript:window.print();', After that you could tinker with what to display there https://www.prestashop.com/forums/topic/325145-how-to-customize-order-page-for-printing/ - same concept here.If you cant make it work with templates and css then you could dive deeper and do some custom work, like making popup window etc.. Edited June 4, 2015 by blackarma (see edit history) Link to comment Share on other sites More sharing options...
acuarelweb Posted July 27, 2015 Author Share Posted July 27, 2015 Thx for your reply blackcarma. Finally i've decided to make a 180 degree turn, and i'm trying now to make my own back office module to accomplish this It involves managing backoffice menu tabs, replicate de orders controller, etc. My goal would be to develope a sort of POS module. Again, thank you very much 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