zen-cart custom search

I just added UPC custom field to the product table, and googling around to find how to make the search recognise this field.

First you have to add a field to the advanced search form. Edit:
/includes/templates/YOUR-TEMPLATE/templates/tpl_advanced_search_default.php file
and add something like this:

  <div><?php echo zen_draw_input_field('YOUR_NEW_FIELD', $sData['your_new_field'], 'onfocus="RemoveFormatString(this, \'' . KEYWORD_FORMAT_STRING . '\')"'); ?>

where you want the new field to appear in the search form.
Then edit the
to “GET” the data from the field by adding something like this:

  $your_new_field =      (isset($_GET['your_new_field'])   ? zen_output_string($_GET['your_new_field']) : '');

now you just (okay, this is the tricky part) need to tell zen-cart to search the new data when something is submitted:

(look for similar looking lines to paste this somewhere in between)
(isset($_GET['your_new_field']) && !is_string($_GET['your_new_field'])) &&

(same thing here: look for similar lines and just paste:
  if (isset($_GET['your_new_field'])) {
    $your_new_field = $_GET['your_new_field'];

(now search for "if (empty($dfrom)" and add somewhere between the &&empty something like this:)
&& empty($your_new_field)

(search for similar and past:)
    $select_column_list .= 'p.your_fieldname_in_db';

(search for similar lines and paste:)
if (isset($_GET['your_new_field']) && zen_not_null($_GET['your_new_field'])) {
  $where_str .= " AND p.your_new_fielname_inDB = :yourfieldnameID";
  $where_str = $db->bindVars($where_str, ':yourfieldnameID', $_GET['your_field_name'], 'string');