I have made a fair amount of modifications to the template files in x-cart version 3.2.2 Gold. I recently noticed that when a product is found in a storefront search it is displayed 4 times.
I note that customer/home_main.tpl (which I haven't changed) is calling customer/main/search_result.tpl (another template I haven't changed) and it is calling customer/main/products.tpl. I have modified this template, but when I replace it with the original template I get the same result, only formatted differently.
The results are displayed with customer/search.php, which I also have not alterred, and I replaced the include/func.php file that I modified with the original file. I can't see how I could have caused this error.
I have looked at the SQL in search.php and I note that it first identifies what categories a product is in and then uses that in the query
Code:
$search_category = addslashes(array_pop(func_query_first("select category from $sql_tbl[categories] where categoryid='$in_category'")));
$search_query = "($sql_tbl[products].product like '%$substring%' or $sql_tbl[products].descr like '%$substring%') and $sql_tbl[categories].category like '$search_category%' and $sql_tbl[products].forsale='Y' $price_condition ".$sort_by_price;
I imported my products with a csv file and separated the fields with semicolons. I selected a default category from the drop down menu and some products were in 3 additional subcategores. Some products had only 1 subcategory. For those products the csv record used empty values, ie. ;2;;; as opposed to ;2;3;4; for a product that was in three subcategories.
This is the only connection I can think of between the 4 displays of the product in the search results. But I would think that this would only happen for products that were assigned to 1 category and 3 subcategories. It also happens when a product is found that is in 1 category and 1 subcategory.