Author Topic: Admin: List Orders - Search is not correct...  (Read 1173 times)

Jason Farmer

  • Beginner
  • *
  • Posts: 49
Admin: List Orders - Search is not correct...
« on: October 17, 2012, 11:35:22 am »
A minor bug ...
vm 2.0.12
administrator\components\com_virtuemart\models\orders.php from Line 216

Code: [Select]
$where[] = implode (' LIKE '.$search.' OR ', $searchFields) . ' LIKE '.$search.' ';
should include braces around the whole thing .. ie.

Code: [Select]
$where[] = '('.implode (' LIKE '.$search.' OR ', $searchFields) . ' LIKE '.$search.') ';
as this $where[] array gets imploded with ' AND ' later on

although its not written very clearly (imho)

I've changed this search on my installation to be case insensitive and made the code a little more clear
Code: [Select]
              $search = $this->_db->getEscaped( strtoupper($search), true );
  $searchFields = array();
$searchFields[] = 'o.order_number';
$searchFields[] = 'u.company';
$searchFields[] = 'u.email';
$searchFields[] = 'u.phone_1';
$searchFields[] = 'u.address_1';
$searchFields[] = 'u.zip';
$searchFields[] = 'CONCAT_WS(" ",u.first_name,u.last_name)';
$searchFields[] = 'CONCAT_WS(" ",u.first_name,u.middle_name,u.last_name)';

$expandSQL = function($search) {
        return function($field) use ($search) {
        return 'UPPER('.$field.') LIKE "%'.$search.'%"';
        };
};

$where[] = '('.implode(' OR ', array_map($expandSQL($search),$searchFields)).')';
DevelopmentProduction
VirtueMart  
2.0.12b
1.1.3
Joomla!  
2.5.6
1.5.14
Mysql 
5.5.8
5.0.51
PhP  
5.3.5
5.2.4