Quote:
Originally Posted by xcell67
damnit, the query will sometimes show a product twice Anyone know how to modify the query so that it will only select an item once?
|
Try this.
Code:
SELECT $sql_tbl[products].*, (SELECT MIN($sql_tbl[pricing].price) FROM $sql_tbl[pricing] WHERE $sql_tbl[pricing].productid=$sql_tbl[products].productid AND $sql_tbl[pricing].quantity=1 AND $sql_tbl[pricing].variantid = 0) AS price FROM $sql_tbl[products],$sql_tbl[pricing] WHERE forsale='Y' AND avail>0 ORDER BY RAND() LIMIT 6
If you use multiple languages or have categories limited to certain members you should look at the queries in recommends.php to sort out modifying the query further for those cases.
If you care about taxed prices and thumbnail images you also need to add just before the smarty assign:
Code:
if (is_array($randoms) && count($randoms) > 0) {
foreach ($randoms as $k=>$v) {
$randoms[$k]["tmbn_url"] = func_get_thumbnail_url($v["productid"]);
$randoms[$k]["taxes"] = func_get_product_taxes($randoms[$k], $login);
}
}