In 1.4.0, If you search "All Categories" for a product that has multiple category designations, it brings up the products multiple times. For an example, see this search for "Macbook Air" on the demo version:
http://demo.opencart.com/index.php?rout ... egory_id=0
I think it has something to do with the getTotalProductsByKeyword function in /catalog/model/catalog/product.php, but I'm not sure. Can someone with more know-how provide a fix? It certainly makes the search less useful when products appear three or four times in a row.
Confirmed.
One Solution (tho maybe not the best):
1. EDIT: catalog/model/catalog/product.php
2. IN THE getProductsByKeyword() FUNCTION, FIND:
3. REPLACE WITH:
Doesn't fix the count, but only returns one.
One Solution (tho maybe not the best):
1. EDIT: catalog/model/catalog/product.php
2. IN THE getProductsByKeyword() FUNCTION, FIND:
Code: Select all
return $query->rows;
Code: Select all
return array_unique($query->rows);
Thanks Q, But what if this KEY WORD has some similar items.
If I replace with your change, I can only search for 1 result. What about the similar items?
Anyone who can find the solution. Thanks!
Allen
If I replace with your change, I can only search for 1 result. What about the similar items?
Anyone who can find the solution. Thanks!
Allen
I know nothing about PHP and SQL, but I still try my best to understand it.
I found a fix, if you don't mind not allowing searching by category. (I had already disabled that, so it works well for me.) Delete the instances of the following piece of code in both getProductsByKeyword() and getTotalProductsByKeyword():
There's three instances of that line in the file (one more in getProductsByCategoryId() ) so be sure not to do just a find-and-replace if you want that function working correctly.
Code: Select all
LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (p.product_id = p2c.product_id)
it should only removes unique items of the exact same id.allenshea wrote:Thanks Q, But what if this KEY WORD has some similar items.
If I replace with your change, I can only search for 1 result. What about the similar items?
Anyone who can find the solution. Thanks!
Allen
So you can have "Apple Monitor" and "Apple Ipod" and if you have monitor in 3 categories and ipod in 2 categories, it should still only return 1 monitor and 1 ipod
-EDIT-
Ah, i see it does not. Ok then... don't use that code. It should probably e done at the db level anyway
Who is online
Users browsing this forum: No registered users and 69 guests