You are here:  » random featured products only from 1 merchant


random featured products only from 1 merchant

Submitted by rolli1 on Fri, 2006-10-27 14:20 in

Hi David,

I use the code provided from you for random featured productsd, but I want to restrict the results to only 1 of 2 merchants. How can I manage that?

Regards

Roland

Submitted by support on Fri, 2006-10-27 14:22

Hi Roland,

Can you post the SQL that you are using at the moment (your line that says $sql = "....") and I will modify it for you to select from only one merchant....

Cheers,
David.

Submitted by rolli1 on Fri, 2006-10-27 14:24

David,
I use that one you provided earlier:

$sql = "SELECT * FROM `".$config_databaseTablePrefix."products` ORDER BY RAND() LIMIT 5";

Roland

Submitted by support on Fri, 2006-10-27 14:28

Hi Roland,

This code picks from the featured products table which does not contain merchant information. Were you actually looking to pick products from your entire database, but only one merchant?

That could be done by using something like this - note that it SELECT's from the products table instead of featured:

  $sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE merchant='Merchant1' ORDER BY RAND() LIMIT 5";

If you want to select from more than one merchant, do something like this:

  $sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE (merchant='Merchant1' OR merchant='Merchant2') ORDER BY RAND() LIMIT 5";

Hope this helps,
Cheers,
David.

Submitted by rolli1 on Fri, 2006-10-27 14:32

Great help,

thank so much.

Roland