morgue86 Posted September 29, 2020 Share Posted September 29, 2020 Hi to all, i've created a module that add a voucher column in the admin order listing. The voucher is displayed correctly but if I want to filter the results the filter doesn't work. I added filter_key but with no results. Can you help me? thanks a lot This is my module code public function hookActionAdminOrdersListingFieldsModifier($params) { if( isset( $params['select'] ) ){ $params['join'] .= ' LEFT JOIN `'._DB_PREFIX_.'order_cart_rule` AS ocr ON (ocr.`id_order` = a.`id_order`) LEFT JOIN `'._DB_PREFIX_.'cart_rule` AS cr ON (ocr.`id_cart_rule` = cr.`id_cart_rule`) '; $params['select'] .= ', GROUP_CONCAT(DISTINCT cr.`code` SEPARATOR \'\n\') AS voucher'; $params['group_by'] .= ' GROUP BY a.`id_order` '; $voucher = array( 'title' => $this->l('Voucher'), 'filter_key' => 'ps_cart_rule!code' ); $params['fields'] = self::array_insert( $params['fields'], [ 'voucher' => $voucher ], 'cname', 'after' ); unset( $params['fields']['payment'] ); unset( $params['fields']['company'] ); } } protected static function array_insert( $array, $pairs, $key, $position = 'after' ) { $key_pos = array_search( $key, array_keys( $array ) ); if ( 'after' == $position ) $key_pos++; if ( false !== $key_pos ) { $result = array_slice( $array, 0, $key_pos ); $result = array_merge( $result, $pairs ); $result = array_merge( $result, array_slice( $array, $key_pos ) ); } else { $result = array_merge( $array, $pairs ); } return $result; } Link to comment Share on other sites More sharing options...
morgue86 Posted September 29, 2020 Author Share Posted September 29, 2020 I have prestashop 1.7.6.4 Link to comment Share on other sites More sharing options...
morgue86 Posted October 5, 2020 Author Share Posted October 5, 2020 hi can you help me? thank you Link to comment Share on other sites More sharing options...
morgue86 Posted October 12, 2020 Author Share Posted October 12, 2020 nobody can help me? Link to comment Share on other sites More sharing options...
squivo Posted May 31, 2022 Share Posted May 31, 2022 (edited) This might help you... https://dev.to/kpodemski/display-extra-column-in-the-prestashop-grid-157j Except the more I read on the subject, it appears the back office orders in Prestashop have not been updated to use symphony, so the "grid" filtering does not work yet: https://stackoverflow.com/questions/63637435/hook-action-order-grid-not-work-in-prestashop-1-7 Which means... there's no obvious answer right now Edited May 31, 2022 by squivo (see edit history) 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