News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Admin: List Orders - Search is not correct...

Started by Jason Farmer, October 17, 2012, 11:35:22 AM

Previous topic - Next topic

Jason Farmer

A minor bug ...
vm 2.0.12
administrator\components\com_virtuemart\models\orders.php from Line 216

$where[] = implode (' LIKE '.$search.' OR ', $searchFields) . ' LIKE '.$search.' ';

should include braces around the whole thing .. ie.

$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
              $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)).')';

[tr][td][/td][td]
Development[/td][td]Production[/td][/tr]
[tr][td]VirtueMart   [/td][td]
2.0.12b
[/td][td]
1.1.3
[/td][/tr]
[tr][td]Joomla!   [/td][td]
2.5.6
[/td][td]
1.5.14
[/td][/tr]
[tr][td]Mysql  [/td][td]
5.5.8
[/td][td]
5.0.51
[/td][/tr]
[tr][td]PhP   [/td][td]
5.3.5
[/td][td]
5.2.4
[/td][/tr]
[/table]