x-cart root -> products.php
AFTER
Code:
// Basic X-cart search of products in category. because if you selected a manufacturer in a category, without this you would only see 1 manufacturer in the drop down box.
$search_data["products"] = array();
$search_data["products"]["categoryid"] = $cat;
$search_data["products"]["search_in_subcategories"] = "";
$search_data["products"]["category_main"] = "Y";
$search_data["products"]["category_extra"] = "Y";
$search_data["products"]["forsale"] = "Y";
$mode = "search";
include $xcart_dir."/include/search.php";
$search_data["products"] = $old_search_data;
$mode = $old_mode;
ADD
Code:
/ If Xcart found some products, loop through all the manufacturers it found and add it to an array...
if($products) {
$advanced_manufacture = array();
$tmp = array();
foreach($products as $key=>$value) { // maybe try unique ?...
if(!in_array($value["manufacturerid"], $tmp)) {
$advanced_manufacture[] = array("manufacturer"=>$value['manufacturer'], "manufacturerid"=>$value['manufacturerid']);
$tmp[] = $value["manufacturerid"];
}
}
}
// assign to smarty
$smarty->assign("found_manu",$advanced_manufacture);
$smarty->assign("manufacturerid",$manufacturerid);
//unset search_data...
unset($search_data);
// NOW research the data but include the manufacturer ID if it found one
$old_search_data = $search_data["products"];
$old_mode = $mode;
$search_data["products"] = array();
$search_data["products"]["categoryid"] = $cat;
// here is where we search for the manufacturer
if ($manufacturerid) $search_data["products"]["manufacturers"] = array($manufacturerid);
$search_data["products"]["search_in_subcategories"] = "";
$search_data["products"]["category_main"] = "Y";
$search_data["products"]["category_extra"] = "Y";
$search_data["products"]["forsale"] = "Y";
$mode = "search";
include $xcart_dir."/include/search.php";
$search_data["products"] = $old_search_data;
$mode = $old_mode;