You are here:  » hybrid random / featured products hard to implement from previous post

Support Forum



hybrid random / featured products hard to implement from previous post

Submitted by haggle on Fri, 2010-06-11 13:56 in

Dave I am having difficulty following the hybrid featured / random product code from this post:
http://www.pricetapestry.com/node/578

Is there any chance of getting some help interpreting the sequence of the programming steps regarding this feature?

I know we all repeat ourselves but your customer support is second to none... I don't want to abuse your kindness but I am unable to follow that thread confidently.

Pete

Submitted by support on Fri, 2010-06-11 14:06

Hi Pete,

No probs - can you describe the featured products functionality you're looking for and I'll work out the code changes for you...

Cheers,
David.

Submitted by haggle on Sat, 2010-06-12 03:04

Awesome I would simply like the following:

On the home page where you have Featured Products I would like to be able to place selected 'Featured Products' MIXED with 'Random Products' which would be changed on each reload.

So the simplest method from what I have read is to run 2 queries and then merge the results in any order on the home page.

It would be fine to have the first three or four 'featured' and the last three or four 'random' but if possible I guess the mix of random and featured on the home page would be ideal but I would be very happy with the queries sequenced in order which I feel would be the easiest to implement.

Thank you for your support Dave.... none IT people who just stepped out on the web like myself greatly appreciate your support. Thanks.

Submitted by support on Sat, 2010-06-12 08:28

Hi,

Sure - look for the following code starting at line 32 of index.php

  $sql = "SELECT * FROM `".$config_databaseTablePrefix."featured` ORDER BY sequence";
  if (database_querySelect($sql,$rows))

...and REPLACE with:

  $sql = "SELECT * FROM `".$config_databaseTablePrefix."featured` ORDER BY sequence";
  database_querySelect($sql,$rows1);
  $sql = "SELECT name,'99' AS sequence FROM `".$config_databaseTablePrefix."products` ORDER BY RAND() LIMIT 3";
  database_querySelect($sql,$rows2);
  $rows = array_merge($rows1,$rows2);
  if (TRUE)

The number of fixed featured products is of course however many you have entered in the Featured Products section in /admin/, and you can control the number of random products by changing the LIMIT value on the 3rd line of the modification...

Hope this helps!

Cheers,
David.

Submitted by haggle on Tue, 2010-06-15 01:55

Thanks Dave... it works like a dream...