proevilz Posted January 9, 2015 Share Posted January 9, 2015 I'm using Prestashop 1.6.0.9. I wish to edit the raw HTML for this part. Full size image link: http://i.stack.imgur.com/hazQp.png I wish to add an extra colum to the filters but I can't actually find the code for it... I have searched through the adminXXXX/themes/default/template/ directory. Specifically the orders files but they only seem to be relevant for the view you get when you actually click on one of the orders listed below. (Below meaning the orders below the filters that you can't see) Does anyone know the actual location for this? Link to comment Share on other sites More sharing options...
vekia Posted January 10, 2015 Share Posted January 10, 2015 it's not a case of template it's a case of controllers /controllers/admin/adminOrdersController.php Link to comment Share on other sites More sharing options...
proevilz Posted January 10, 2015 Author Share Posted January 10, 2015 it's not a case of template it's a case of controllers /controllers/admin/adminOrdersController.php Alright, so let's say I used this in overrides to display emails. class AdminOrdersController extends AdminOrdersControllerCore { public function __construct() { parent::__construct(); $this->_select = $this->_select.', c.email as email'; $this->fields_list['email'] = array( 'title' => $this->l('Email'), 'align' => 'text-center', 'class' => 'fixed-width-xs' ); } } I'm trying to create a filter based on which carrier is selected in the order... The carrier selection isn't contained within the _orders table which the controller selects. How can I go about creating an orders filter? Link to comment Share on other sites More sharing options...
bellini13 Posted January 10, 2015 Share Posted January 10, 2015 (edited) I'm not sure you will be able to do this using an override, I will let you figure that part out. I have provided a patched AdminOrdersController class showing you how to accomplish what I believe you want to do. Edit 1/11: Refactored due to issue with select filter. Since the id_carrier column exists within the orders table, I have removed the usage of the orders_carrier table Step 1: For the filter drop down, you need to create an array to store the carrier names. protected $statuses_array = array(); protected $carriers_array = array(); Step 2: You need to fill the array in step 1 with all the available Carrier names. This will be used to fill the select filter with all available options $carriers = Carrier::getCarriers((int)$this->context->language->id); foreach ($carriers as $carrier) $this->carriers_array[$carrier['id_carrier']] = $carrier['name']; Step 3: You need to add your data to the 'fields_list' array. 'id_carrier' => array( 'title' => $this->l('Carrier'), 'type' => 'select', 'list' => $this->carriers_array, 'filter_key' => 'a!id_carrier', 'filter_type' => 'int', 'align' => 'text-center', 'callback' => 'setOrderCarrierName', 'orderby' => false, ) Step 4: You need to create a static function that maps the id_carrier to the carrier name. This is used in step 3 public static function setOrderCarrierName($id_carrier, $tr) { $carrier = new Carrier($tr['id_carrier']); return $carrier->name; } Edited January 11, 2015 by bellini13 (see edit history) 2 Link to comment Share on other sites More sharing options...
proevilz Posted January 10, 2015 Author Share Posted January 10, 2015 I'm not sure you will be able to do this using an override, I will let you figure that part out. I have provided a patched AdminOrdersController class showing you how to accomplish what I believe you want to do. Step 1: For the filter drop down, you need to create an array to store the carrier names. protected $statuses_array = array(); protected $carriers_array = array(); Step 2: You need to update the select statement to include the id_carrier from the order_carrier table $this->_select = ' oc.id_carrier, a.id_currency, a.id_order AS id_pdf, CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`, osl.`name` AS `osname`, os.`color`, IF((SELECT COUNT(so.id_order) FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new, country_lang.name as cname, IF(a.valid, 1, 0) badge_success'; Step 3: You need to update the join statement to include joining the order and order_carrier tables $this->_join = ' LEFT JOIN `'._DB_PREFIX_.'order_carrier` oc ON (oc.`id_order` = a.`id_order`) LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`) INNER JOIN `'._DB_PREFIX_.'address` address ON address.id_address = a.id_address_delivery INNER JOIN `'._DB_PREFIX_.'country` country ON address.id_country = country.id_country INNER JOIN `'._DB_PREFIX_.'country_lang` country_lang ON (country.`id_country` = country_lang.`id_country` AND country_lang.`id_lang` = '.(int)$this->context->language->id.') LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = a.`current_state`) LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)$this->context->language->id.')'; Step 4: You need to fill the array in step 1 with all the available Carrier names $carriers = Carrier::getCarriers((int)$this->context->language->id); foreach ($carriers as $carrier) $this->carriers_array[$carrier['id_carrier']] = $carrier['name']; Step 5: You need to add your data to the 'fields_list' array. 'id_carrier' => array( 'title' => $this->l('Carrier'), 'type' => 'select', 'list' => $this->carriers_array, 'filter_key' => 'oc!id_order_carrier', 'filter_type' => 'int', 'align' => 'text-center', 'callback' => 'setOrderCarrierName', 'orderby' => false, ) Step 6: You need to create a static function that maps the id_carrier to the carrier name. This is used in step 5 public static function setOrderCarrierName($id_carrier, $tr) { $carrier = new Carrier($tr['id_carrier']); return $carrier->name; } That's epic! But there is one small problem... When applying the filter, only 1 result is shown. It's as if you have LIMIT 1 on the query... Any ideas? Link to comment Share on other sites More sharing options...
bellini13 Posted January 10, 2015 Share Posted January 10, 2015 it works properly for me, so perhaps you did not apply it correctly. Link to comment Share on other sites More sharing options...
proevilz Posted January 10, 2015 Author Share Posted January 10, 2015 it works properly for me, so perhaps you did not apply it correctly. Can you confirm it lists more than one result/order per carrier you select from the drop down? Here is my controller, I'm sure it's correct. http://pastiebin.com/54b18c97bce78 Link to comment Share on other sites More sharing options...
bellini13 Posted January 11, 2015 Share Posted January 11, 2015 Yes, you are correct. There was an issue with the select filter. I have refactored the solution and updated my original post. Link to comment Share on other sites More sharing options...
proevilz Posted January 11, 2015 Author Share Posted January 11, 2015 Yes, you are correct. There was an issue with the select filter. I have refactored the solution and updated my original post. Thank you Bellini, that issue is now resolved. Link to comment Share on other sites More sharing options...
JordanESSystems Posted May 15, 2015 Share Posted May 15, 2015 Is it possible to do this using a product attribute instead of carrier? I've looked all over the forums and this is as close a solution I can find. 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