You are here:  » Featured Products

Support Forum



Featured Products

Submitted by babrees on Fri, 2009-01-23 10:26 in

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

Submitted by support on Fri, 2009-01-23 11:17

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.

Submitted by babrees on Fri, 2009-01-23 11:35

Thanks David! Both worked a charm - You are ACE!

---------
Jill

Submitted by babrees on Fri, 2009-03-20 16:16

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

Submitted by support on Fri, 2009-03-20 21:13

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.

Submitted by babrees on Fri, 2009-03-20 21:20

PERFECT! Thanks once again David

---------
Jill