I have featured products set up to randomly select. Is it possible to...
(1) restrict results to specific merchant?
(2) restrict results to specific search?
Jill
Thanks David! Both worked a charm - You are ACE!
---------
Jill
Hi David
Just setting up a site with random featured products by 3 keywords. I want all keywords in the product but it is find any one of them.
I have my search.php modified as per http://www.pricetapestry.com/node/2136 and that works well.
---------
Jill
Hi Jill,
To do this, in place of:
$sql = "SELECT name,1 AS sequence FROM `".$config_databaseTablePrefix."products` WHERE MATCH name AGAINST ('Some Search Terms') ORDER BY RAND() LIMIT 3";
...use:
$sql = "SELECT name,1 AS sequence FROM `".$config_databaseTablePrefix."products` WHERE MATCH name AGAINST ('+Some +Search +Terms' IN BOOLEAN MODE) ORDER BY RAND() LIMIT 3";
Cheers,
David.
Hi Jill,
Yes - both can be done quite easily with an appropriate WHERE clause added to the featured products SQL. Assuming that you have used the modified SQL code from this thread, the following will restrict by merchant:
$sql = "SELECT name,1 AS sequence FROM `".$config_databaseTablePrefix."products` WHERE merchant='Some Merchant' ORDER BY RAND() LIMIT 3";
...or to restrict by search:
$sql = "SELECT name,1 AS sequence FROM `".$config_databaseTablePrefix."products` WHERE MATCH name AGAINST ('Some Search Terms') ORDER BY RAND() LIMIT 3";
Cheers,
David.