示例#1
0
 /**
  * This function is used to evaluate the product with search  option
  * @param integer $id
  * 
  * @return string
  */
 function evaluate($id)
 {
     $searchoption = $_SESSION['search_option'];
     $arr = "";
     for ($i = 0; $i < count($searchoption); $i++) {
         $key = key($searchoption);
         $val = $searchoption[$key];
         if ($key != '' && $key != 'Brand' && $key != 'Price') {
             $attr[] .= $val;
         }
         next($searchoption);
     }
     //$len_attr=strlen($attr);
     //$attr=substr($attr,0,($len_attr-1));
     $sql = "SELECT product_id FROM products_table WHERE category_id=" . $id . " ";
     if ($searchoption['Brand']) {
         $sql .= " and brand='" . $searchoption['Brand'] . "'";
     }
     if ($searchoption['Price']) {
         $sql .= " and msrp='" . $searchoption['Price'] . "'";
     }
     $query = new Bin_Query();
     if ($query->executeQuery($sql)) {
         $arr_val = $query->records;
     }
     if (count($attr) > 0) {
         for ($i = 0; $i < count($arr_val); $i++) {
             $sql_query = "SELECT attrib_value_id FROM product_attrib_values_table WHERE product_id=" . $arr_val[$i]['product_id'];
             $query = new Bin_Query();
             if ($query->executeQuery($sql_query)) {
                 $tmp = $query->records;
             }
             $val = "";
             for ($j = 0; $j < count($tmp); $j++) {
                 $val[] .= $tmp[$j][attrib_value_id];
             }
             if (Core_CFeaturedItems::inArray($val, $attr)) {
                 $product_id .= $arr_val[$i]['product_id'] . ",";
             }
         }
         $len_product_id = strlen($product_id);
         $product_id = substr($product_id, 0, $len_product_id - 1);
         return $product_id;
     } else {
         for ($i = 0; $i < count($arr_val); $i++) {
             $product_id .= $arr_val[$i]['product_id'];
             if ($i != count($arr_val) - 1) {
                 $product_id .= ",";
             }
         }
         return $product_id;
     }
 }