Page 1 of 1
v.1.4.6 - Sort by price not working, Search returns dups
Posted: Tue Apr 06, 2010 10:16 am
by Goober
Hi,
There are two issues here.
1. Looking at the Demo site use this link
Keyword Search on letter 'a'. Please note that the first four items returned in the search are links to the same item, 'Apply Cinema 30'. This item appears in multiple categories.
Suggestion, return unique items.
2. Using the search results from above, sort the items by price Low > High. Please note item returned in the 8th position. The price of the item is £1,175. This item is between items prices at £100 and and £235.
Not sure what/where the problem is here. But clearly the sort is off.
Thanks!
Love what you've done with the cart.
Re: v.1.4.6 - Sort by price not working, Search returns dups
Posted: Tue Apr 06, 2010 11:28 am
by rph
It looks like Daniel probably duped the Apple Cinema monitor a bunch of times when testing the new copy function. You'll notice they all have different product IDs. So it's not a bug, just an issue with the demo store (in previous versions a product would have multiple returns if it was in multiple categories; I don't know if that was ever changed).
The Sony VAIO is a good catch. It appears the comma is the issue.
Re: v.1.4.6 - Sort by price not working, Search returns dups
Posted: Tue Apr 06, 2010 9:27 pm
by Goober
rph wrote:It looks like Daniel probably duped the Apple Cinema monitor a bunch of times when testing the new copy function. You'll notice they all have different product IDs. So it's not a bug, just an issue with the demo store (in previous versions a product would have multiple returns if it was in multiple categories; I don't know if that was ever changed).
The Sony VAIO is a good catch. It appears the comma is the issue.
Yep, you are correct, the dups are the result of over active copy function.
that just leaves the sort by price issue.
thanks
/Goober
Re: v.1.4.6 - Sort by price not working, Search returns dups
Posted: Thu Apr 08, 2010 6:52 am
by dunester
Having the same pricing issue here.
On low to high $17.95 come before $4.95 - seems to be looking at each number individually i.e. the 1 in $17.95 is lower than the 4 in $4.95 so it gets put first.
Re: v.1.4.6 - Sort by price not working, Search returns dups
Posted: Thu Apr 08, 2010 7:45 am
by rph
Yeah, the problem is the sort is doing everything as strings. Here's a real quick fix for it:
/catalog/model/catalog/product.php
Change:
Code: Select all
$sort_data = array(
'pd.name',
'p.price',
'rating'
);
if (in_array($sort, $sort_data)) {
$sql .= " ORDER BY LCASE(" . $sort . ")";
} else {
$sql .= " ORDER BY LCASE(pd.name)";
}
To:
Code: Select all
$sort_data = array(
'LCASE(pd.name)',
'p.price',
'rating'
);
if (in_array($sort, $sort_data)) {
$sql .= " ORDER BY " . $sort;
} else {
$sql .= " ORDER BY LCASE(pd.name)";
}
Re: v.1.4.6 - Sort by price not working, Search returns dups
Posted: Thu Apr 08, 2010 12:25 pm
by Qphoria
fixed. thanks.
Re: v.1.4.6 - Sort by price not working, Search returns dups
Posted: Tue Sep 28, 2010 11:26 pm
by Boekel
How to fix this in 1.4.8b?
Re: v.1.4.6 - Sort by price not working, Search returns dups
Posted: Thu Sep 30, 2010 11:28 pm
by Boekel
bump
Re: v.1.4.6 - Sort by price not working, Search returns dups
Posted: Sat Oct 16, 2010 4:09 am
by ocatfni
We are running v1.4.8 and I have found the error that doesn't allow for sorting by price.
In that same file (/catalog/model/catalog/product.php), the 'p.price' sort option is missing from the array.
This error occurs in multiple places on this page in functions for sorting by category, manufacturer, tags, keyword, and specials.
BEFORE:
Code: Select all
$sort_data = array(
'pd.name',
'p.sort_order',
'special',
'rating'
);
AFTER:
Code: Select all
$sort_data = array(
'pd.name',
'p.price',
'p.sort_order',
'special',
'rating'
);
I also noticed that 'special' is incorrectly included in the list in most of these functions as well.
The specials info isn't available for sorting because the table is not included in the SQL query.
Re: v.1.4.6 - Sort by price not working, Search returns dups
Posted: Wed Nov 17, 2010 4:39 pm
by Boekel
dunester wrote:Having the same pricing issue here.
On low to high $17.95 come before $4.95 - seems to be looking at each number individually i.e. the 1 in $17.95 is lower than the 4 in $4.95 so it gets put first.
I have this problem in the backend.
They are sorted like this:
Name:
1.000 stuks
10.000 stuks
100 stuks
but I want to sort them like this:
Name:
100 stuks
1.000 stuks
10.000 stuks
without removing the '.'
Re: v.1.4.6 - Sort by price not working, Search returns dups
Posted: Wed Dec 08, 2010 7:34 pm
by wizardhomefitness.
ocatfni wrote:We are running v1.4.8 and I have found the error that doesn't allow for sorting by price.
In that same file (/catalog/model/catalog/product.php), the 'p.price' sort option is missing from the array.
This error occurs in multiple places on this page in functions for sorting by category, manufacturer, tags, keyword, and specials.
BEFORE:
Code: Select all
$sort_data = array(
'pd.name',
'p.sort_order',
'special',
'rating'
);
AFTER:
Code: Select all
$sort_data = array(
'pd.name',
'p.price',
'p.sort_order',
'special',
'rating'
);
I also noticed that 'special' is incorrectly included in the list in most of these functions as well.
The specials info isn't available for sorting because the table is not included in the SQL query.
Hi Guys,
I was having the same issue with my products not sort properly by price. I have edited the code as explained above, now it's almost working as it should be but just one product is now out of order?
I'm pretty limited when it comes to editing code etc so I don't want to start messing around with too much, if anyone has any ideas I would appreciate it. As I said the above fix worked to some extent but for some reason one product in still out of order, although there is only around 10 products on the page I was testing.
Thanks,
Pat