Here's the updated version:
Code:
<?php
/**
* @package plugins
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: Designed for v1.5.4 $
*/
class zcObserverSearchInUpc extends base
{
public function __construct()
{
$this->attach ($this, array ('NOTIFY_SEARCH_WHERE_STRING'));
}
public function update (&$class, $eventID)
{
switch ($eventID) {
case 'NOTIFY_SEARCH_WHERE_STRING':
global $where_str, $keywords, $db;
if (isset ($keywords) && zen_not_null ($keywords)) {
if (zen_parse_search_string (stripslashes ($keywords), $search_keywords)) {
$keyword_str = " OR (p.UPC != '' AND (";
for ($i=0, $n = sizeof ($search_keywords); $i<$n; $i++ ) {
switch ($search_keywords[$i]) {
case '(':
case ')':
case 'and':
case 'or':
$keyword_str .= " " . $search_keywords[$i] . " ";
break;
default:
$keyword_str .= " p.UPC LIKE '%:keywords:%' ";
$keyword_str = $db->bindVars ($keyword_str, ':keywords:', $search_keywords[$i], 'noquotestring');
break;
}
}
$keyword_str .= " ) )";
$where_str = str_replace ('))', $keyword_str . ' ))', $where_str);
}
}
break;
default:
break;
}
}
}