$s=get_search_query();
$args = array('s' =>$s);
$defaultSearchTitle = "Search Results for:";
$busca = get_query_var('s');
$buscar = "+".str_replace(" "," +",$busca);
//$buscar = $busca;
//OBTER LISTA DE PRODUTOS 3D
//$sql = $wpdb->prepare("SELECT * FROM 3dcrystal_product_categories LEFT JOIN 3dcrystal_products ON 3dcrystal_products.id = 3dcrystal_product_categories.productid WHERE 3dcrystal_products.name LIKE %s LIMIT 99",Array($buscar));
//SELECT * FROM 3dcrystal_product_categories LEFT JOIN 3dcrystal_products ON 3dcrystal_products.id = 3dcrystal_product_categories.productid WHERE MATCH (reference,name,shortdesc,fulldesc) AGAINST (%s IN NATURAL LANGUAGE MODE) LIMIT 99
// IN BOOLEAN MODE
$sql = $wpdb->prepare("SELECT * FROM 3dcrystal_product_categories LEFT JOIN 3dcrystal_categories ON (3dcrystal_categories.id = 3dcrystal_product_categories.categoryid) LEFT JOIN 3dcrystal_products ON 3dcrystal_products.id = 3dcrystal_product_categories.productid WHERE MATCH (reference,name,shortdesc,fulldesc) AGAINST (%s IN BOOLEAN MODE) AND active = 1 LIMIT 99",Array($buscar));
//echo $sql;
$r = $wpdb->get_results($sql, ARRAY_A);
$productlist = "";
$i = 1;
$c = 0;
$inlist = Array();
foreach($r as $product){
$pid = $product['id'];
if($inlist[$pid] != 1){
$inlist[$pid] = 1;
$cls = "one_third";
$image = "";
//get product image
unset($r1);
$sql = $wpdb->prepare("SELECT id,file,description,image_title,image_alt,background FROM 3dcrystal_images WHERE productid = %d ORDER BY ordem ASC LIMIT 1",Array($product['id']));
$r1 = $wpdb->get_results($sql, ARRAY_A);
$bg = "";
if($r1[0]['file'] != ""){
$img_title = $r1[0]['description'];
$img_alt = $r1[0]['description'];
if($r1[0]['image_title'] != ""){$img_title = $r1[0]['image_title'];}
if($r1[0]['image_alt'] != ""){$img_alt = $r1[0]['image_alt'];}
$url = "/wp-content/plugins/3dcrystal/xcrud/uploads/".$r1[0]['file'];
$image = "";
if($r1[0]['background'] != ""){
$r1[0]['background'] = str_replace("#","",$r1[0]['background']);
$bg = "style='background:#".$r1[0]['background']."!important'";
}
}
if($i==3){$cls = "one_third et_column_last";}
$slug = $product['slug'];
$productslug = sanitize_title($product['name']);
$productlist .= "";//
";
if($i==3){
$productlist .= "";
$i=0;
}
$i++;
$c++;
}
}
if($cls != "one_third et_column_last"){
$productlist .= "$title
$excerpt
Products related to your search: $busca
"; echo $productlist; $weHaveResults = 1; } if($defaultCount>0){ echo "$defaultSearchTitle $busca
"; echo $resultadosDefault; $weHaveResults = 1; } if ($weHaveResults == 0){ echo 'Nothing Found for '.$busca.'
Sorry, but nothing matched your search criteria. Please try again with some different keywords.