Is there any way to show 5 featured products randomly from the list of featured products.
Best Regards
Nazeel
Hi David,
I use this upper code, but I want to restrict the results to only 1 of 2 merchants. How can I manage that?
Regards
Roland
Sorry for bumping such an old thread but i want precisely this, i tried the edit but it seems the same products on the home page (where i have the featured products)
what should be the code to alter daily the products in a random way?
So users will see top 5 of the day or something like this.
Hi,
If you want the same 5 products to be the "featured products of the day", changing at random daily (but staying constant in any 24hr period), you could do this as follows. Considering the latest distribution which I believe you are running; look for the following code on line 33 of index.php:
$sql = "SELECT * FROM `".$config_databaseTablePrefix."featured` ORDER BY sequence";
...and REPLACE that with:
$seed = strtotime("Y-m-d",time());
$sql = "SELECT *,1 AS sequence FROM `".$config_databaseTablePrefix."featured` ORDER BY RAND(".$seed.")";
Hope this helps!
Cheers,
David.
Well i tried it, but i still cant know if it will works. How can i put that to change hourly? So i will test and see in less time ;)
Hehe
Try
$seed = strtotime("Y-m-d H:00:00",time());
Cheers,
David.
Hi
isnt working.
Im using the template revolution i bought on pricetapestrytemplates.com
Could be that???
Hi,
I just noticed a mistake in the replacement code above, this line:
$sql = "SELECT *,1 AS sequence FROM `".$config_databaseTablePrefix."featured` ORDER BY RAND(".$seed.")";
...should be:
$sql = "SELECT name,1 AS sequence FROM `".$config_databaseTablePrefix."products` ORDER BY RAND(".$seed.") LIMIT 5";
That should be all it is...
Cheers,
David.
Hi Nazeel,
The featured products are selected with this code on line 32 of index.php:
$sql = "SELECT * FROM `".$config_databaseTablePrefix."featured` ORDER BY sequence";
To make it pick 5 random products from the list of featured products, change that line to the following:
$sql = "SELECT * FROM `".$config_databaseTablePrefix."featured` ORDER BY RAND() LIMIT 5";
Cheers,
David.