You are here:  » Random products not showing via index.php

Support Forum



Random products not showing via index.php

Submitted by marco@flapper on Wed, 2011-11-23 13:41 in

Hi,
Somehow the products aren't showing on the frontpage. I use the random products function.

<?php
  require("includes/common.php");
  $header["meta"]["description"] = $config_metaDescriptionIndex;
  $header["meta"]["keywords"] = $config_metaKeywordsIndex;
  require("html/header.php");
  require("html/searchform.php");
  //print javascript_focus("search.q");
  $featuredproducts_merchantRandom = "Nationale-Vacaturebank";
  require("featuredproducts.php");
 $featuredproducts_categoryRandom = "Productie-Uitvoerend";
  require("featuredproducts.php");
   $featuredproducts_categoryRandom = "Gezondheid-Paramedisch-Zorg";
  require("featuredproducts.php");
   $featuredproducts_categoryRandom = "Administratief-Boekhouding";
  require("featuredproducts.php");
   $featuredproducts_categoryRandom = "Onderwijs-Onderzoek-Wetenschap";
  require("featuredproducts.php");
    $featuredproducts_categoryRandom = "Commercieel-Verkoop";
  require("featuredproducts.php");
     $featuredproducts_categoryRandom = "Beveiliging-Veiligheid";
  require("featuredproducts.php");
    require("html/footer.php");
  ?>
 

Submitted by support on Wed, 2011-11-23 16:40

Hi Marco,

That all looks fine - please could you email me your featuredproducts.php script and I'll check it out further...

Cheers,
David.
--
PriceTapestry.com

Submitted by marco@flapper on Thu, 2011-11-24 10:17

Thanks.

I hyphenated the merchants / categories are hyphenated instead of using actually the
exact merchant / category names as they appear on the A-Z lists. Now it works.

Submitted by marco@flapper on Thu, 2011-11-24 13:45

Hi,
I noticed the featuredproducts.php is only showing 'products' from one merchant. Is there a way it selects/random more merchants to show?

In my featuredproducts.php I have:

$sql = "SELECT name,1 AS sequence FROM `".$config_databaseTablePrefix."products` WHERE merchant = '".$featuredproducts_merchantRandom."' AND price >= 0 AND price <= 999.00 ORDER BY RAND() LIMIT 3";
}
elseif ($featuredproducts_categoryRandom)
{
$sql = "SELECT name,1 AS sequence FROM `".$config_databaseTablePrefix."products` WHERE category = '".$featuredproducts_categoryRandom."' ORDER BY merchant LIMIT 3";
}
else
{
$sql = "SELECT * FROM `".$config_databaseTablePrefix."featured` WHERE name LIKE '".$featuredproducts_category."/%' ORDER BY merchant";

Submitted by support on Thu, 2011-11-24 13:57

Hi Marco,

It looks like the code only has a merchantRandom version in place. If you wanted to add an all merchants random, replace that section (and the enclosing IF statement) with:

if ($featuredproducts_random)
{
$sql = "SELECT name,1 AS sequence FROM `".$config_databaseTablePrefix."products` WHERE price >= 0 AND price <= 999.00 ORDER BY RAND() LIMIT 3";
$featuredproducts_random = FALSE;
}
elseif ($featuredproducts_merchantRandom)
{
$sql = "SELECT name,1 AS sequence FROM `".$config_databaseTablePrefix."products` WHERE merchant = '".$featuredproducts_merchantRandom."' AND price >= 0 AND price <= 999.00 ORDER BY RAND() LIMIT 3";
}
elseif ($featuredproducts_categoryRandom)
{
$sql = "SELECT name,1 AS sequence FROM `".$config_databaseTablePrefix."products` WHERE category = '".$featuredproducts_categoryRandom."' ORDER BY merchant LIMIT 3";
}
else
{
$sql = "SELECT * FROM `".$config_databaseTablePrefix."featured` WHERE name LIKE '".$featuredproducts_category."/%' ORDER BY merchant";
}

...and then in your calling code, use:

  $featuredproducts_random = TRUE;
  require("featuredproducts.php");

Cheers,
David.
--
PriceTapestry.com

Submitted by marco@flapper on Thu, 2011-11-24 15:30

Hi,
It still uses one merchant.

Submitted by support on Thu, 2011-11-24 15:40

Hi Marco,

If you would like to forward your new version of featuredproducts.php and include your new calling code in the email I'll check it out for you...

Cheers,
David.
--
PriceTapestry.com