You are here:  » Multiple Featured Product Categories

Support Forum



Multiple Featured Product Categories

Submitted by mikebrad0927 on Tue, 2007-06-12 14:54 in

Great Script!

Just wondering if it's possible to have multiple sets of featured products.

Submitted by support on Tue, 2007-06-12 14:59

Hi Mike,

Thank you for your comments. That's not something that is supported as it stands, but shouldn't be too hard to implement by copying the existing featured products database table and creating a copy of admin/featured.php, changing every instance that refers to the "featured" database table to the name of your new table.

Then, it would be a case of copying the code from index.php (lines 32 to 68 in the distribution) again changing the name of the database table to display featured products from your additional categories...

Cheers,
David.

Submitted by mikebrad0927 on Tue, 2007-06-12 15:36

Dave,

Thanks for the super quick reply. It works fine, thank you. I also added a little link in admin/admin_menu.php to make it easier on myself.

It was very easy to do.

Thanks again.

Submitted by Bakalinge on Thu, 2012-12-20 18:14

Hi David,

I just tried to use this tip to get 2 sets of featured products on the home page. I did like mentionned aboved, just duplicating in index.php this part of code (I just replaced the new database table name) :

  $sql = "SELECT * FROM `".$config_databaseTablePrefix."featurednew` ORDER BY sequence";
  if (database_querySelect($sql,$rows))
  {
    $sqlNames = array();
    foreach($rows as $featured)
    {
      $sqlNames[] = "'".$featured["name"]."'";
    }
    $sqlIn = implode(",",$sqlNames);
    $sql = "SELECT * , MIN( price ) AS minPrice, MAX( price ) AS maxPrice, COUNT( id ) AS numMerchants FROM `".$config_databaseTablePrefix."products` WHERE name IN (".$sqlIn.") GROUP BY name";
    database_querySelect($sql,$rows);
    $featured["products"] = $rows;
    foreach($featured["products"] as $k => $product)
    {
      if ($config_useRewrite)
      {
        $featured["products"][$k]["productHREF"] = "products/".tapestry_hyphenate($product["name"]).".html";
        $featured["products"][$k]["reviewHREF"] = "reviews/".tapestry_hyphenate($product["name"]).".html";
      }
      else
      {
        $featured["products"][$k]["productHREF"] = "products.php?q=".urlencode($product["name"]);
        $featured["products"][$k]["reviewHREF"] = "reviews.php?q=".urlencode($product["name"]);
      }
    }
  }

As result, I get a new area with featured products, but they are still the same products as the main featured products area . Of course, I changed the products in the "featurednew" table, but the problem remains...I also tried to modify all variable names, but..

Do I have to modify something else in the code above ? Or somewhere else ?

Thanks !

Bak

Submitted by support on Thu, 2012-12-20 18:34

Hi Bak,

I'm wondering looking at the above whether your new table has been created without the default database table prefix, as if not the query would fail, and the $featured variable would remain set from the previous (original) query.

The default $config_databaseTablePrefix (from your config.php file at line 30) is pt_ so make sure that your new table is actually called pt_featurednew in your database and I think that should be all it is...!

Cheers,
David.
--
PriceTapestry.com

Submitted by Bakalinge on Thu, 2012-12-20 18:50

Hi David,

Thanks for your answer !

I just checked and the table get the pt_ Table Prefix...
it's like if I the $feature variable "memorized" the first result. But I also tried to change its name...

Submitted by support on Thu, 2012-12-20 18:58

Hi Bak,

It may be worth adding:

  unset($featured);

...between sections - that should ensure that nothing carries; but also you could enable database debug mode as that might reveal the problem. You can do this by changing line 6 in config.advanced.php as follows:

  $config_databaseDebugMode = TRUE;

...that might reveal the problem - if you're still not sure let me know what (if anything) is displayed and I'll check it out...

Cheers,
David.
--
PriceTapestry.com

Submitted by Bakalinge on Thu, 2012-12-20 19:04

David,

Adding :

unset($featured);

changed the all the products from both featured product area : now I can see on both blocs the products from the...featurednew table :)

The DebugMode doesn't give any message :(

Thanks

Submitted by support on Thu, 2012-12-20 19:21

Hi Bak,

Please could you email me your modified index.php and I'll check it all out for you...

Cheers,
David.
--
PriceTapestry.com