You are here:  » Random featured products


Random featured products

Submitted by IG on Thu, 2016-03-10 20:29 in

Hi David

I am using (testing) automatic product mapping by ean. So far so good.

I was wondering how I can display on the homepage only random featured products, which were automatically mapped by ean?

Kind regards,
Ivo

Submitted by support on Sat, 2016-03-12 10:07

Hello Ivo,

Sure - the standard instructions for random Featured Products are here. The only way to determine that a product was mapped is if name is not equal to original_name (and has an ean), so to include this condition in the WHERE clause, you could use as the first replacement:

  $sql = "SELECT DISTINCT(name),1 AS sequence FROM `".$config_databaseTablePrefix."products` WHERE ean <> '' AND name <> original_name ORDER BY RAND() LIMIT 3";

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by IG on Sat, 2016-04-30 10:24

Hi David

This works, but it seems it is quite heavy on my server resources. Please correct me, if I am wrong.

Would it help to first define 5 merchants from which to chose these products from? And if so, how would I do that?

Kind regards,
Ivo

Submitted by support on Sun, 2016-05-01 08:38

Hello Ivo,

Selecting a random merchant and then random Featured Products from that merchant is the method suggested in the latest random Featured Products mod, however if you'd prefer to use a pre-defined list of merchants this can be done simply using an IN expression as part of the WHERE clause - have a go with;

  $sql = "SELECT DISTINCT(name),1 AS sequence FROM `".$config_databaseTablePrefix."products` WHERE ean <> '' AND name <> original_name AND merchant IN ('Merchant 1','Merchant 2','Merchant 3') ORDER BY RAND() LIMIT 3";

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by IG on Thu, 2017-10-26 09:03

Hi David

Finally, I integrated the above code and it works great.

How can I add the condition that the minimum price of the featured products is > 100?

Cheers, IG

Submitted by support on Thu, 2017-10-26 09:14

Hello Ivo,

Have a go with;

  $sql = "SELECT DISTINCT(name),1 AS sequence FROM `".$config_databaseTablePrefix."products` WHERE ean <> '' AND price > '100.00' AND name <> original_name AND merchant IN ('Merchant 1','Merchant 2','Merchant 3') ORDER BY RAND() LIMIT 3";

Cheers,
David.
--
PriceTapestry.com

Submitted by IG on Thu, 2017-10-26 09:34

Hi David

Spot on as always.

There are simply no words for your unbelievable and relentless support!

Cheers,
Ivo