The SQL isn't just built on one line; it is constructed over the course of several lines of code considering the query type (normal search, merchant: etc.), the sort order and page / offset.
The main bulk of the SQL is generated in each of the switch cases (lines 36 though 62 in the distribution), and for a default product search it is the code after the "default:" case.
The ordering SQL is then added to the base SQL (the core query that selects the products) on line 84:
$sql .= " ORDER BY ".$orderBySelection[$sort];
...where $orderBySelection[$sort] is "minPrice ASC" - minPrice being a summary value created in the main SQL as follows:
SELECT * , MIN( price ) AS minPrice
If you want to study the complete query, the easiest thing to do would be to print it out, round about line 90, just before:
Hi Dave,
The SQL isn't just built on one line; it is constructed over the course of several lines of code considering the query type (normal search, merchant: etc.), the sort order and page / offset.
The main bulk of the SQL is generated in each of the switch cases (lines 36 though 62 in the distribution), and for a default product search it is the code after the "default:" case.
The ordering SQL is then added to the base SQL (the core query that selects the products) on line 84:
$sql .= " ORDER BY ".$orderBySelection[$sort];
...where $orderBySelection[$sort] is "minPrice ASC" - minPrice being a summary value created in the main SQL as follows:
SELECT * , MIN( price ) AS minPrice
If you want to study the complete query, the easiest thing to do would be to print it out, round about line 90, just before:
database_querySelect($sqlResultCount,$rows);
...for example:
print "<p>".$sql."</p>";
Hope this helps!
Cheers,
David.