Jump to content

How to add more filter keys to AdminOrder.php


Recommended Posts


I think the subject says it all, in my case, there is a column in ps_orders table that I would like to use to filter the order list in BO, I changed the code in method __contruct of class AdminOrder.php like this:

  $this->_select = '
  a.id_order AS id_pdf, ';
/*pe extention */
  $this->_select.= ' oh.date_add as oh_date_add, ';
/*pe extetnion */
  CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`,
  osl.`name` AS `osname`,
  IF((SELECT COUNT(so.id_order) FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer AND so.valid = 1) > 1, 0, 1) as new,
  (SELECT COUNT(od.`id_order`) FROM `'._DB_PREFIX_.'order_detail` od WHERE od.`id_order` = a.`id_order` GROUP BY `id_order`) AS product_number';
  $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`)
  LEFT JOIN `'._DB_PREFIX_.'order_history` oh ON (oh.`id_order` = a.`id_order`)
 LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = oh.`id_order_state`)
 LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)($cookie->id_lang).')';
 $this->_where = 'AND oh.`id_order_history` = (SELECT MAX(`id_order_history`) FROM `'._DB_PREFIX_.'order_history` moh WHERE moh.`id_order` = a.`id_order` GROUP BY moh.`id_order`)';

  $this->fieldsDisplay = array(
 'id_order' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 55),
 'new' => array('title' => $this->l('New'), 'width' => 25, 'align' => 'center', 'type' => 'bool', 'filter_key' => 'new', 'tmpTableFilter' => true, 'icon' => array(0 => 'blank.gif', 1 => 'news-new.gif'), 'orderby' => false),
 'customer' => array('title' => $this->l('Customer'), 'widthColumn' => 160, 'width' => 140, 'filter_key' => 'customer', 'tmpTableFilter' => true),
 'total_paid' => array('title' => $this->l('Total'), 'width' => 70, 'align' => 'right', 'prefix' => '<b>', 'suffix' => '</b>', 'price' => true, 'currency' => true),
 'payment' => array('title' => $this->l('Payment'), 'width' => 100),
 'osname' => array('title' => $this->l('Status'), 'widthColumn' => 230, 'type' => 'select', 'select' => $statesArray, 'filter_key' => 'os!id_order_state', 'filter_type' => 'int', 'width' => 200),
 'date_add' => array('title' => $this->l('Date'), 'width' => 65, 'align' => 'right', 'type' => 'datetime', 'filter_key' => 'a!date_add'),
/* pe extention delivery estimated date */
 'deliveryestimated' => array('title' => $this->l('Del.Es.'), 'width' => 65, 'align' => 'right', 'type' => 'datetime', 'filter_key' => 'a!deliveryestimated'),
/* --pe extention delivery estimated date */
/* pe extention last status date*/
  'oh_date_add' => array('title' => $this->l('Status Date'), 'width' => 65, 'align' => 'right', 'type' => 'datetime', 'filter_key' => 'oh_date_add','tmpTableFilter' => true),
/* -- last status date */
  'id_pdf' => array('title' => $this->l('PDF'), 'callback' => 'printPDFIcons', 'orderby' => false, 'search' => false));

I added a column deliveryestimated to ps_orders and extended Order.php to include this new field , but after changin this line of code in AdminOrder.php, everytime I access the Order tab in BO I am getting a security message error(when I try to filter the list using this new field or any other in the list) , please see the attached image.

If I remove the line of code I added, everything works fine.

Thanks for any help in this point.




Link to comment
Share on other sites

  • 4 weeks later...
  • 1 year later...



as we are 2 years later, you probably don't follow anymore this topic, and probably had an aswer anyway. As yu seem still activ on the forum, in case you still follow;...We also have a problem of filter on BO (1.5.3) , but we didn't find any other topics on that subject, if you solved anything we would be very interested. I'll post the subject.


This error page is frequent if you change frequently your profil. did you went a step further like "clic " on the " I understand the risk and really want to display this page" ?

We frequently have it beacause we use some link where we deleted the "URL part" dealing with access permissions. so Each time presta ask us if we really want to display this particular page.

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...