Ver Mensaje Individual
  #2 (permalink)  
Antiguo 24/03/2011, 15:04
viajeaperu
 
Fecha de Ingreso: marzo-2010
Mensajes: 57
Antigüedad: 14 años, 1 mes
Puntos: 1
Respuesta: error en archivo advanced_search_result.php

Código PHP:
// BOF Separate Pricing Per Customer
   
$status_tmp_product_prices_table false;
   
$status_need_to_get_prices false;
   
// find out if sorting by price has been requested
   
if ( (isset($HTTP_GET_VARS['sort'])) && (ereg('[1-8][ad]'$HTTP_GET_VARS['sort'])) && (substr($HTTP_GET_VARS['sort'], 01) <= sizeof($column_list)) ){
    
$_sort_col substr($HTTP_GET_VARS['sort'], 1);
    if (
$column_list[$_sort_col-1] == 'PRODUCT_LIST_PRICE') {
      
$status_need_to_get_prices true;
      }
   }
   
   if ((
tep_not_null($pfrom) || tep_not_null($pto) || $status_need_to_get_prices == true) && $customer_group_id != '0') { 
   
$product_prices_table TABLE_PRODUCTS_GROUP_PRICES.$customer_group_id;
   
// the table with product prices for a particular customer group is re-built only a number of times per hour
   // (setting in /includes/database_tables.php called MAXIMUM_DELAY_UPDATE_PG_PRICES_TABLE, in minutes)
   // to trigger the update the next function is called (new function that should have been
   // added to includes/functions/database.php)
   
tep_db_check_age_products_group_prices_cg_table($customer_group_id);
   
$status_tmp_product_prices_table true;   
   } elseif ((
tep_not_null($pfrom) || tep_not_null($pto) || $status_need_to_get_prices == true) && $customer_group_id == '0') {
   
// to be able to sort on retail prices we *need* to get the special prices instead of leaving them
   // NULL and do product_listing the job of getting the special price
   // first make sure that table exists and needs no updating
   
tep_db_check_age_specials_retail_table();
   
$status_tmp_special_prices_table true;
   } 
// end elseif ((tep_not_null($pfrom) || (tep_not_null($pfrom)) && .... 
   
   
if ($status_tmp_product_prices_table == true) {
   
$select_str "select distinct " $select_column_list " m.manufacturers_id, p.products_id, pd.products_name, tmp_pp.products_price, p.products_tax_class_id, if(tmp_pp.status, tmp_pp.specials_new_products_price, NULL) as specials_new_products_price, IF(tmp_pp.status, tmp_pp.specials_new_products_price, tmp_pp.products_price) as final_price ";
   } elseif (
$status_tmp_special_prices_table == true) {
     
$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 ";   
   } else {
     
$select_str "select distinct " $select_column_list " m.manufacturers_id, p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, NULL as specials_new_products_price, NULL as final_price ";   
   }
   
// next line original select query
   // $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 ";


  
if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {
    
$select_str .= ", SUM(tr.tax_rate) as tax_rate ";
  }
  
/*anterior con el maco
      if ($status_tmp_product_prices_table == true) {
  $from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id) left join " . $product_prices_table . " as tmp_pp using(products_id)";
  
      } elseif ($status_tmp_special_prices_table == true) {
  $from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id) left join " . TABLE_SPECIALS_RETAIL_PRICES . " s on p.products_id = s.products_id ";
      } else {
  $from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id) ";
      }
  */
            
if ($status_tmp_product_prices_table == true) {
  
$from_str "from " TABLE_PRODUCTS " p left join " TABLE_MANUFACTURERS " m using(manufacturers_id), " TABLE_PRODUCTS_DESCRIPTION " pd left join " $product_prices_table " as tmp_pp using(products_id), " TABLE_CATEGORIES " c, " TABLE_PRODUCTS_TO_CATEGORIES " p2c";
          } elseif (
$status_tmp_special_prices_table == true) {
  
$from_str "from " TABLE_PRODUCTS " p left join " TABLE_MANUFACTURERS " m using(manufacturers_id), " TABLE_PRODUCTS_DESCRIPTION " pd left join " TABLE_SPECIALS_RETAIL_PRICES " s on pd.products_id = s.products_id , " TABLE_CATEGORIES " c, " TABLE_PRODUCTS_TO_CATEGORIES " p2c";
          } else {
  
$from_str "from " TABLE_PRODUCTS " p left join " TABLE_MANUFACTURERS " m using(manufacturers_id), " TABLE_PRODUCTS_DESCRIPTION " pd left join " TABLE_SPECIALS " s on pd.products_id = s.products_id, " TABLE_CATEGORIES " c, " TABLE_PRODUCTS_TO_CATEGORIES " p2c";
          }
  
// EOF Separate Pricing Per Customer

  
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 "')";
  }

  
$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) . "%'";
          
$where_str .= ')';
          break;
      }
    }
    
$where_str .= " )";
  }

  if (
tep_not_null($dfrom)) {
    
$where_str .= " and p.products_date_added >= '" tep_date_raw($dfrom) . "'";
  }