You are here:  » Featured products based upon current month and keywords for that month

Support Forum



Featured products based upon current month and keywords for that month

Submitted by chrisst1 on Sat, 2011-02-12 10:38 in

Hi David

After working with PT for a few years and having quite a few installations running, the most time consuming area is finding and adding featured products. We've tried random featured products and other mods based on merchant which are OK but do not target seasonal products. So we've been thinking of ways to make the featured products less time consuming but still keeping the featured products seasonally themed.

This is the idea we have come up with:

Randon featured products based upon the current month using a predefined list of keywords for that month.

For example for party products in October the keywords would be something like halloween, mask, pumpkins, etc.

What do you think and can you help with this?

Chris

Submitted by support on Sat, 2011-02-12 15:20

Hi Chris,

No problem at all - this can be done with a CASE statement and a simple extension of the random Featured Products mod from this thread.

To make things dynamic based on the month; in place of the suggested replacement SQL of

$sql = "SELECT name,1 AS sequence FROM `".$config_databaseTablePrefix."products` ORDER BY RAND() LIMIT 3";

...have a go with something like this:

$seasonalKeywords = array();
switch(date("m")) // 1=Jan,12=Dec
{
  case 10:
   $seasonalKeywords = array("halloween","mask","pumpkins");
   break;
  case 12:
   $seasonalKeywords = array("christmas","party","santa");
   break;
}
if (count($seasonalKeywords))
{
  $wheres = array();
  foreach($seasonalKeywords as $seasonalKeyword)
  {
    $wheres[] = " name LIKE '%".database_safe($seasonalKeyword)."%' ";
  }
  $where = implode(" OR ",$wheres);
  $sql = "SELECT name,1 AS sequence FROM `".$config_databaseTablePrefix."products` WHERE ".$where." ORDER BY RAND() LIMIT 3";
}
else
{
  // default to random featured products if no seasonal keywords configured
  $sql = "SELECT name,1 AS sequence FROM `".$config_databaseTablePrefix."products` ORDER BY RAND() LIMIT 3";
}

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by chrisst1 on Tue, 2011-02-15 13:46

Hi David

That looks very interesting, would there be any limit to the amount of keywords that can be used per month?

I will test it out later this week.

Many thanks

Chris

Submitted by support on Tue, 2011-02-15 13:54

Hi Chris,

There's no limit from a code / operation point of view!

Cheers,
David.
--
PriceTapestry.com

Submitted by chrisst1 on Mon, 2011-02-21 16:17

Hi David

I've been having a go with the above and it works great, just wondering whether we can get it to..

First: Check for admin entered featured products first then if less than X amount

Second: Run the code above if keywords added

Third: Else then grab random products

Chris

Submitted by support on Mon, 2011-02-21 17:34

Hi Chris,

Do you want random products to take up the slack in any case to a given X Featured Products, e.g.

admin + seasonal + random = X

Cheers,
David.
--
PriceTapestry.com

Submitted by chrisst1 on Tue, 2011-02-22 11:56

Hi David

I think (for us) that would defeat the idea of seasonal products. When I said x amount I ment the sql LIMIT which we have set at 9.

So if that amount has not been manually entered via the admin run the new code

Hope that makes sense

Chris

Submitted by support on Tue, 2011-02-22 12:44

Hi Chris,

I'm with you - should be straight forward but not so easy to describe as the mods need to be merged in different places - could you email me your index.php and I'll make the changes for you...

Cheers,
David.
--
PriceTapestry.com

Submitted by chrisst1 on Wed, 2011-02-23 17:16

Hi David

Thank you for getting that sorted for us, once the kewords are in it's going to save a lot of time each week.

You support is still as good as when you started.

Thank you very much.

Chris