Jump to content
Sign in to follow this  
steven78

Extra Product Fields 1.0

Recommended Posts

Very nice contrib!

 

I would like to know if there's a way to put these variables to the advanced search box contrib. (advsearch.php)

 

Maybe it is very easy to do so, but....

 

The code of advsearch.php is:

<!-- search //-->

<tr>

<td>

<?php

$info_box_contents = array();

$info_box_contents[] = array('text' => BOX_HEADING_ADVSEARCH);

 

new infoBoxHeading($info_box_contents, false, false);

 

$info_box_contents = array();

$info_box_contents[] = array('form' => tep_draw_form('advanced_search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get'),

'text' => '<table border="0" width="100%" cellspacing="0" cellpadding="1"><tr><td class="infoBoxContents" valign="top" colspan="3">' . BOX_ADVSEARCH_KW . '</td></tr><tr><td class="infoBoxContents" valign="top" colspan="3">' . tep_draw_hidden_field('search_in_description','1') . tep_draw_input_field('keywords', '', 'size="15" maxlength="30" style="width: ' . (BOX_WIDTH-30) . 'px"') . tep_image_submit('button_quick_find.gif', BOX_HEADING_ADVSEARCH) . '</td></tr><tr><td class="infoBoxContents" valign="top" colspan="3">' . BOX_ADVSEARCH_PRICERANGE . '</td></tr><tr><td class="infoBoxContents" valign="top" colspan="3">' . tep_draw_input_field('pfrom','','size="3" maxlength="4"') . BOX_ADVSEARCH_PRICESEP . tep_draw_input_field('pto','','size="3" maxlength="4"') . '</td></tr><tr><td class="infoBoxContents" valign="top" colspan="3">' . BOX_ADVSEARCH_CAT . '</td></tr><tr><td class="infoBoxContents" valign="top" colspan="3">' . tep_draw_pull_down_menu('categories_id', tep_get_categories(array(array('id' => '', 'text' => BOX_ADVSEARCH_ALLCAT)))) . '</td></tr></table>');

 

new infoBox($info_box_contents);

?>

</td>

</tr>

<!-- search_eof //-->

 

The code of advanced_search.php with the Extra Product Fields 1.0 is:

<?php

// begin Extra Product Fields

$epf_query = tep_db_query("select e.epf_id, e.epf_uses_value_list, l.epf_label from " . TABLE_EPF . " e join " . TABLE_EPF_LABELS . " l where e.epf_status and e.epf_advanced_search and (e.epf_id = l.epf_id) and (l.languages_id = " . (int)$languages_id . ") and l.epf_active_for_language order by e.epf_order");

$epf = array();

while ($e = tep_db_fetch_array($epf_query)) {

$epf[] = array('id' => $e['epf_id'],

'label' => $e['epf_label'],

'uses_list' => $e['epf_uses_value_list'],

'field' => 'extra_value' . ($e['epf_uses_value_list'] ? '_id' : '') . $e['epf_id']);

}

// end Extra Product Fields

?>

 

 

 

-------

 

 

<tr>

<td class="fieldKey"><?php echo ENTRY_MANUFACTURERS; ?></td>

<td class="fieldValue"><?php echo tep_draw_pull_down_menu('manufacturers_id', tep_get_manufacturers(array(array('id' => '', 'text' => TEXT_ALL_MANUFACTURERS)))); ?></td>

</tr>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<?php

// begin Extra Product Fields

foreach ($epf as $e) {

?>

<tr>

<td class="fieldKey"><?php echo $e['label']; ?></td>

<td class="fieldValue">

<?php if ($e['uses_list']) {

echo tep_draw_pull_down_menu($e['field'], tep_build_epf_pulldown($e['id'], $languages_id, array(array('id' => '', 'text' => TEXT_ANY_VALUE))));

} else {

echo tep_draw_input_field($e['field'], '', 'style="width: 300px"');

} ?>

</td>

</tr>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<?php

}

// end Extra Product Fields

?>

 

 

<tr>

<td class="fieldKey"><?php echo ENTRY_PRICE_FROM; ?></td>

<td class="fieldValue"><?php echo tep_draw_input_field('pfrom'); ?></td>

</tr>

<tr>

<td class="fieldKey"><?php echo ENTRY_PRICE_TO; ?></td>

<td class="fieldValue"><?php echo tep_draw_input_field('pto'); ?></td>

</tr>

 

Is there a way to integrate this in advsearch.php box?

 

Please help

Share this post


Link to post
Share on other sites

It should be easy enough. The first section of code that builds the epf array you will copy directly from advanced_search.php since no changes need to be made to it. The section that displays the fields will need to be modified somewhat to work in the info box. I would probably do it as follows:

$extras = '';
foreach ($epf as $e) {
 $extras .= '<tr><td class="infoBoxContents valign="top" colspan="3">' . $e['label'] . '</td></tr><tr><td class="infoBoxContents valign="top" colspan="3">';
 if ($e['uses_list']) {
   $extras .= tep_draw_pull_down_menu($e['field'], tep_build_epf_pulldown($e['id'], $languages_id, array(array('id' => '', 'text' => TEXT_ANY_VALUE))));
 } else {
   $extras .= tep_draw_input_field($e['field']);
 }
 $extras .= '</td></tr>';
}

 

Then all you need to do is splice the $extras variable into the statement that sets $info_box_contents[] in the postion where you want it to appear. If you want the extras at the end break the:

 

'</td></tr></table>'

 

into

 

'</td></tr>' . $extras . '</table>'

 

If you want it to appear somewhere in the middle then break any </tr><tr> pair into this:

 

</tr>' . $extras . '<tr>

 

If you insert the extra fields before the price as I did in advanced_search.php then your final file would look like this:

<!-- search //-->
<tr>
<td>
<?php
$info_box_contents = array();
$info_box_contents[] = array('text' => BOX_HEADING_ADVSEARCH);

new infoBoxHeading($info_box_contents, false, false);

// begin Extra Product Fields
$epf_query = tep_db_query("select e.epf_id, e.epf_uses_value_list, l.epf_label from " . TABLE_EPF . " e join " . TABLE_EPF_LABELS . " l where e.epf_status and e.epf_advanced_search and (e.epf_id = l.epf_id) and (l.languages_id = " . (int)$languages_id . ") and l.epf_active_for_language order by e.epf_order");
$epf = array();
while ($e = tep_db_fetch_array($epf_query)) {
$epf[] = array('id' => $e['epf_id'],
'label' => $e['epf_label'],
'uses_list' => $e['epf_uses_value_list'],
'field' => 'extra_value' . ($e['epf_uses_value_list'] ? '_id' : '') . $e['epf_id']);
}
$extras = '';
foreach ($epf as $e) {
 $extras .= '<tr><td class="infoBoxContents valign="top" colspan="3">' . $e['label'] . '</td></tr><tr><td class="infoBoxContents valign="top" colspan="3">';
 if ($e['uses_list']) {
   $extras .= tep_draw_pull_down_menu($e['field'], tep_build_epf_pulldown($e['id'], $languages_id, array(array('id' => '', 'text' => TEXT_ANY_VALUE))));
 } else {
   $extras .= tep_draw_input_field($e['field']);
 }
 $extras .= '</td></tr>';
}
// end Extra Product Fields
$info_box_contents = array();
$info_box_contents[] = array('form' => tep_draw_form('advanced_search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get'),
'text' => '<table border="0" width="100%" cellspacing="0" cellpadding="1"><tr><td class="infoBoxContents" valign="top" colspan="3">' . BOX_ADVSEARCH_KW . '</td></tr><tr><td class="infoBoxContents" valign="top" colspan="3">' . tep_draw_hidden_field('search_in_description','1') . tep_draw_input_field('keywords', '', 'size="15" maxlength="30" style="width: ' . (BOX_WIDTH-30) . 'px"') . tep_image_submit('button_quick_find.gif', BOX_HEADING_ADVSEARCH) . '</td></tr>' $extras . '<tr><td class="infoBoxContents" valign="top" colspan="3">' . BOX_ADVSEARCH_PRICERANGE . '</td></tr><tr><td class="infoBoxContents" valign="top" colspan="3">' . tep_draw_input_field('pfrom','','size="3" maxlength="4"') . BOX_ADVSEARCH_PRICESEP . tep_draw_input_field('pto','','size="3" maxlength="4"') . '</td></tr><tr><td class="infoBoxContents" valign="top" colspan="3">' . BOX_ADVSEARCH_CAT . '</td></tr><tr><td class="infoBoxContents" valign="top" colspan="3">' . tep_draw_pull_down_menu('categories_id', tep_get_categories(array(array('id' => '', 'text' => BOX_ADVSEARCH_ALLCAT)))) . '</td></tr></table>');

new infoBox($info_box_contents);
?>
</td>
</tr>
<!-- search_eof //-->

Very nice contrib!

 

I would like to know if there's a way to put these variables to the advanced search box contrib. (advsearch.php)

 

Maybe it is very easy to do so, but....

 

The code of advsearch.php is:

 

 

The code of advanced_search.php with the Extra Product Fields 1.0 is:

 

 

Is there a way to integrate this in advsearch.php box?

 

Please help

Share this post


Link to post
Share on other sites

Thanks wdepot!

 

I copied the code into advsearch.php. The page works, but the results are always all products!

 

 

The url gives:

 

/advanced_search_result.php?x=6&y=4&extra_value_id1=1&extra_value_id2=&extra_value_id3=&extra_value_id8=&pfrom=&pto=&categories_id=

 

I integrated the right code in advanced_search_results.php:

 

<?php

/*

$Id: advanced_search_result.php 1739 2007-12-20 00:52:16Z hpdl $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

require('includes/application_top.php');

 

require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ADVANCED_SEARCH);

 

// begin Extra Product Fields

$epf_query = tep_db_query("select e.epf_id, e.epf_uses_value_list, e.epf_advanced_search, e.epf_show_parent_chain, e.epf_show_in_listing, l.epf_label from " . TABLE_EPF . " e join " . TABLE_EPF_LABELS . " l where e.epf_status and (e.epf_id = l.epf_id) and (l.languages_id = " . (int)$languages_id . ") and l.epf_active_for_language order by e.epf_order");

$epf = array();

while ($e = tep_db_fetch_array($epf_query)) { // retrieve all active extra fields

$epf[] = array('id' => $e['epf_id'],

'label' => $e['epf_label'],

'uses_list' => $e['epf_uses_value_list'],

'show_chain' => $e['epf_show_parent_chain'],

'search' => $e['epf_advanced_search'],

'listing' => $e['epf_show_in_listing'],

'field' => 'extra_value' . ($e['epf_uses_value_list'] ? '_id' : '') . $e['epf_id']);

}

$epf_empty = true;

$epf_values = array();

foreach ($epf as $e) {

if ($e['search']) // only advanced searchable fields will have separate values

if (isset($HTTP_GET_VARS[$e['field']]) && !empty($HTTP_GET_VARS[$e['field']])) {

$epf_empty = false;

$epf_values[] = $HTTP_GET_VARS[$e['field']];

}

}

// end Extra Product Fields

 

 

$error = false;

 

if ( (isset($HTTP_GET_VARS['keywords']) && empty($HTTP_GET_VARS['keywords'])) &&

// begin Extra Product Fields

$epf_empty &&

(isset($HTTP_GET_VARS['categories_id']) && empty($HTTP_GET_VARS['categories_id'])) &&

(isset($HTTP_GET_VARS['manufacturers_id']) && empty($HTTP_GET_VARS['manufacturers_id'])) &&

// end Extra Product Fields

 

(isset($HTTP_GET_VARS['dfrom']) && (empty($HTTP_GET_VARS['dfrom']) || ($HTTP_GET_VARS['dfrom'] == DOB_FORMAT_STRING))) &&

(isset($HTTP_GET_VARS['dto']) && (empty($HTTP_GET_VARS['dto']) || ($HTTP_GET_VARS['dto'] == DOB_FORMAT_STRING))) &&

(isset($HTTP_GET_VARS['pfrom']) && !is_numeric($HTTP_GET_VARS['pfrom'])) &&

(isset($HTTP_GET_VARS['pto']) && !is_numeric($HTTP_GET_VARS['pto'])) ) {

$error = true;

 

$messageStack->add_session('search', ERROR_AT_LEAST_ONE_INPUT);

} else {

$dfrom = '';

$dto = '';

$pfrom = '';

$pto = '';

$keywords = '';

 

 

 

if (isset($HTTP_GET_VARS['dfrom'])) {

$dfrom = (($HTTP_GET_VARS['dfrom'] == DOB_FORMAT_STRING) ? '' : $HTTP_GET_VARS['dfrom']);

}

 

if (isset($HTTP_GET_VARS['dto'])) {

$dto = (($HTTP_GET_VARS['dto'] == DOB_FORMAT_STRING) ? '' : $HTTP_GET_VARS['dto']);

}

 

if (isset($HTTP_GET_VARS['pfrom'])) {

$pfrom = $HTTP_GET_VARS['pfrom'];

}

 

if (isset($HTTP_GET_VARS['pto'])) {

$pto = $HTTP_GET_VARS['pto'];

}

 

if (isset($HTTP_GET_VARS['keywords'])) {

$keywords = $HTTP_GET_VARS['keywords'];

}

 

$date_check_error = false;

if (tep_not_null($dfrom)) {

if (!tep_checkdate($dfrom, DOB_FORMAT_STRING, $dfrom_array)) {

$error = true;

$date_check_error = true;

 

$messageStack->add_session('search', ERROR_INVALID_FROM_DATE);

}

}

 

if (tep_not_null($dto)) {

if (!tep_checkdate($dto, DOB_FORMAT_STRING, $dto_array)) {

$error = true;

$date_check_error = true;

 

$messageStack->add_session('search', ERROR_INVALID_TO_DATE);

}

}

 

if (($date_check_error == false) && tep_not_null($dfrom) && tep_not_null($dto)) {

if (mktime(0, 0, 0, $dfrom_array[1], $dfrom_array[2], $dfrom_array[0]) > mktime(0, 0, 0, $dto_array[1], $dto_array[2], $dto_array[0])) {

$error = true;

 

$messageStack->add_session('search', ERROR_TO_DATE_LESS_THAN_FROM_DATE);

}

}

 

$price_check_error = false;

if (tep_not_null($pfrom)) {

if (!settype($pfrom, 'double')) {

$error = true;

$price_check_error = true;

 

$messageStack->add_session('search', ERROR_PRICE_FROM_MUST_BE_NUM);

}

}

 

if (tep_not_null($pto)) {

if (!settype($pto, 'double')) {

$error = true;

$price_check_error = true;

 

$messageStack->add_session('search', ERROR_PRICE_TO_MUST_BE_NUM);

}

}

 

if (($price_check_error == false) && is_float($pfrom) && is_float($pto)) {

if ($pfrom >= $pto) {

$error = true;

 

$messageStack->add_session('search', ERROR_PRICE_TO_LESS_THAN_PRICE_FROM);

}

}

 

if (tep_not_null($keywords)) {

if (!tep_parse_search_string($keywords, $search_keywords)) {

$error = true;

 

$messageStack->add_session('search', ERROR_INVALID_KEYWORDS);

}

}

// begin Extra Product Fields

if (tep_not_null($epf_values)) {

foreach ($epf_values as $value) {

if (!tep_parse_search_string($value, $epf_value_keywords)) {

$error = true;

$messageStack->add_session('search', ERROR_INVALID_KEYWORDS . $value );

}

}

}

// end Extra Product Fields

}

 

 

 

if (empty($dfrom) && empty($dto) && empty($pfrom) && empty($pto) && empty($keywords)

// begin Extra Product Fields

&& !tep_not_null($epf_values) &&

(isset($HTTP_GET_VARS['categories_id']) && empty($HTTP_GET_VARS['categories_id'])) &&

(isset($HTTP_GET_VARS['manufacturers_id']) && empty($HTTP_GET_VARS['manufacturers_id']))

// end Extra Product Fields

) {

 

 

 

$error = true;

 

$messageStack->add_session('search', ERROR_AT_LEAST_ONE_INPUT);

}

 

if ($error == true) {

tep_redirect(tep_href_link(FILENAME_ADVANCED_SEARCH, tep_get_all_get_params(), 'NONSSL', true, false));

}

 

$breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ADVANCED_SEARCH));

$breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, tep_get_all_get_params(), 'NONSSL', true, false));

?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html <?php echo HTML_PARAMS; ?>>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">

<title><?php echo TITLE; ?></title>

<link rel="stylesheet" type="text/css" href="stylesheet.css">

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">

<!-- header //-->

<?php require(DIR_WS_INCLUDES . 'header.php'); ?>

<!-- header_eof //-->

 

<!-- body //-->

<table border="0" width="100%" cellspacing="3" cellpadding="3">

<tr>

<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">

<!-- left_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>

<!-- left_navigation_eof //-->

</table></td>

<!-- body_text //-->

<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td class="pageHeading"><?php echo HEADING_TITLE_2; ?></td>

<td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_browse.gif', HEADING_TITLE_2, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

</tr>

</table></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<tr>

<td>

<?php

// create column list

$define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL,

'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME,

'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER,

'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE,

'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY,

'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT,

'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE,

'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW);

 

asort($define_list);

 

$column_list = array();

reset($define_list);

while (list($key, $value) = each($define_list)) {

if ($value > 0) $column_list[] = $key;

}

 

$select_column_list = '';

 

for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {

switch ($column_list[$i]) {

case 'PRODUCT_LIST_MODEL':

$select_column_list .= 'p.products_model, ';

break;

case 'PRODUCT_LIST_MANUFACTURER':

$select_column_list .= 'm.manufacturers_name, ';

break;

case 'PRODUCT_LIST_QUANTITY':

$select_column_list .= 'p.products_quantity, ';

break;

case 'PRODUCT_LIST_IMAGE':

$select_column_list .= 'p.products_image, ';

break;

case 'PRODUCT_LIST_WEIGHT':

$select_column_list .= 'p.products_weight, ';

break;

}

}

 

$select_str = "select distinct " . $select_column_list . " m.manufacturers_id, p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price ";

 

// begin Extra Product Fields

foreach ($epf as $e) {

$select_str .= ', pd.' . $e['field'] . ' ';

}

// end Extra Product Fields

 

 

if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {

$select_str .= ", SUM(tr.tax_rate) as tax_rate ";

}

 

 

$from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id";

 

if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {

if (!tep_session_is_registered('customer_country_id')) {

$customer_country_id = STORE_COUNTRY;

$customer_zone_id = STORE_ZONE;

}

$from_str .= " left join " . TABLE_TAX_RATES . " tr on p.products_tax_class_id = tr.tax_class_id left join " . TABLE_ZONES_TO_GEO_ZONES . " gz on tr.tax_zone_id = gz.geo_zone_id and (gz.zone_country_id is null or gz.zone_country_id = '0' or gz.zone_country_id = '" . (int)$customer_country_id . "') and (gz.zone_id is null or gz.zone_id = '0' or gz.zone_id = '" . (int)$customer_zone_id . "')";

}

 

$from_str .= ", " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c";

 

$where_str = " where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id ";

 

if (isset($HTTP_GET_VARS['categories_id']) && tep_not_null($HTTP_GET_VARS['categories_id'])) {

if (isset($HTTP_GET_VARS['inc_subcat']) && ($HTTP_GET_VARS['inc_subcat'] == '1')) {

$subcategories_array = array();

tep_get_subcategories($subcategories_array, $HTTP_GET_VARS['categories_id']);

 

$where_str .= " and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and (p2c.categories_id = '" . (int)$HTTP_GET_VARS['categories_id'] . "'";

 

for ($i=0, $n=sizeof($subcategories_array); $i<$n; $i++ ) {

$where_str .= " or p2c.categories_id = '" . (int)$subcategories_array[$i] . "'";

}

 

$where_str .= ")";

} else {

$where_str .= " and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['categories_id'] . "'";

}

}

 

if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {

$where_str .= " and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'";

}

 

if (isset($search_keywords) && (sizeof($search_keywords) > 0)) {

$where_str .= " and (";

for ($i=0, $n=sizeof($search_keywords); $i<$n; $i++ ) {

switch ($search_keywords[$i]) {

case '(':

case ')':

case 'and':

case 'or':

$where_str .= " " . $search_keywords[$i] . " ";

break;

default:

$keyword = tep_db_prepare_input($search_keywords[$i]);

$where_str .= "(pd.products_name like '%" . tep_db_input($keyword) . "%' or p.products_model like '%" . tep_db_input($keyword) . "%' or m.manufacturers_name like '%" . tep_db_input($keyword) . "%'";

 

if (isset($HTTP_GET_VARS['search_in_description']) && ($HTTP_GET_VARS['search_in_description'] == '1')) $where_str .= " or pd.products_description like '%" . tep_db_input($keyword) . "%'";

// begin Extra Product Fields

if (isset($HTTP_GET_VARS['search_in_description']) && ($HTTP_GET_VARS['search_in_description'] == '1')) // extra fields are part of product description and so should be searched only if searching in descriptions

foreach ($epf as $e) {

if (!$e['uses_list']) // can only search directly entered fields and not ones chosen from a list

$where_str .= " or pd." . $e['field'] . " like '%" . tep_db_input($keyword) . "%'";

}

// end Extra Fields Contribution

 

$where_str .= ')';

break;

}

}

$where_str .= " )";

}

 

// begin Extra Product Fields

foreach ($epf as $e) {

if ($e['search']) { // only process advanced searchable fields

$value = '';

if (isset($HTTP_GET_VARS[$e['field']]) && !empty($HTTP_GET_VARS[$e['field']]))

$value = $HTTP_GET_VARS[$e['field']]; // get value passed from advanced_search.php

if ($e['uses_list']) {

if ($value != '') $where_str .= " and (pd." . $e['field'] . " in (" . (int)$value . tep_list_epf_children($value) . "))";

} else {

unset($epf_value_keywords); // erase any keywords from previous field

tep_parse_search_string($value, $epf_value_keywords);

if (isset($epf_value_keywords) && (sizeof($epf_value_keywords) > 0)) {

$where_str .= " and (";

for ($i=0, $n=sizeof($epf_value_keywords); $i<$n; $i++ ) {

switch ($epf_value_keywords[$i]) {

case '(':

case ')':

case 'and':

case 'or':

$where_str .= " " . $epf_value_keywords[$i] . " ";

break;

default:

$keyword = tep_db_prepare_input($epf_value_keywords[$i]);

$where_str .= "(pd." . $e['field'] . " like '%" . tep_db_input($keyword) . "%')";

break;

}

}

$where_str .= ")";

}

}

}

}

// end Extra Product Fields

 

 

 

if (tep_not_null($dfrom)) {

$where_str .= " and p.products_date_added >= '" . tep_date_raw($dfrom) . "'";

}

 

if (tep_not_null($dto)) {

$where_str .= " and p.products_date_added <= '" . tep_date_raw($dto) . "'";

}

 

if (tep_not_null($pfrom)) {

if ($currencies->is_set($currency)) {

$rate = $currencies->get_value($currency);

 

$pfrom = $pfrom / $rate;

}

}

 

if (tep_not_null($pto)) {

if (isset($rate)) {

$pto = $pto / $rate;

}

}

 

if (DISPLAY_PRICE_WITH_TAX == 'true') {

if ($pfrom > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) * if(gz.geo_zone_id is null, 1, 1 + (tr.tax_rate / 100) ) >= " . (double)$pfrom . ")";

if ($pto > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) * if(gz.geo_zone_id is null, 1, 1 + (tr.tax_rate / 100) ) <= " . (double)$pto . ")";

} else {

if ($pfrom > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) >= " . (double)$pfrom . ")";

if ($pto > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) <= " . (double)$pto . ")";

}

 

if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {

$where_str .= " group by p.products_id, tr.tax_priority";

}

 

if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('[1-8][ad]', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) {

for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {

if ($column_list[$i] == 'PRODUCT_LIST_NAME') {

$HTTP_GET_VARS['sort'] = $i+1 . 'a';

$order_str = ' order by pd.products_name';

break;

}

}

} else {

$sort_col = substr($HTTP_GET_VARS['sort'], 0 , 1);

$sort_order = substr($HTTP_GET_VARS['sort'], 1);

$order_str = ' order by ';

switch ($column_list[$sort_col-1]) {

case 'PRODUCT_LIST_MODEL':

$order_str .= "p.products_model " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";

break;

case 'PRODUCT_LIST_NAME':

$order_str .= "pd.products_name " . ($sort_order == 'd' ? "desc" : "");

break;

case 'PRODUCT_LIST_MANUFACTURER':

$order_str .= "m.manufacturers_name " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";

break;

case 'PRODUCT_LIST_QUANTITY':

$order_str .= "p.products_quantity " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";

break;

case 'PRODUCT_LIST_IMAGE':

$order_str .= "pd.products_name";

break;

case 'PRODUCT_LIST_WEIGHT':

$order_str .= "p.products_weight " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";

break;

case 'PRODUCT_LIST_PRICE':

$order_str .= "final_price " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";

break;

}

}

 

$listing_sql = $select_str . $from_str . $where_str . $order_str;

 

require(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING);

?>

</td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<tr>

<td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_ADVANCED_SEARCH, tep_get_all_get_params(array('sort', 'page')), 'NONSSL', true, false) . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>

</tr>

</table></td>

<!-- body_text_eof //-->

<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">

<!-- right_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>

<!-- right_navigation_eof //-->

</table></td>

</tr>

</table>

<!-- body_eof //-->

 

<!-- footer //-->

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

<!-- footer_eof //-->

<br>

</body>

</html>

<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

 

I think it is a problem in advanced_search_results.php instead of adv_search.php

 

Can you please help?

Share this post


Link to post
Share on other sites

In product_listing we have in the header that allows the sorting of the products by Name, Manufacturer, Model, ... and Price. With this - great - contribution the header gets a wrong format.

Can we add the fields of Extra Field into the list of sorting?

Thanks

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×