Hi everyone,
Here is a script that will check that all Featured Products are valid and send you an email alert if one or more no longer exist so that you can take action to update your site...
<?php
require("../includes/common.php");
$msg = "";
$sql = "SELECT name FROM `".$config_databaseTablePrefix."featured`";
if (database_querySelect($sql,$products))
{
foreach($products as $product)
{
$parts = explode("/",$product["name"]);
$name = (isset($parts[1])?$parts[1]:$parts[0]);
$sql = "SELECT id FROM `".$config_databaseTablePrefix."products`
WHERE name='".database_safe($name)."' LIMIT 1";
if (!database_querySelect($sql,$result))
{
$msg .= $name." - NO LONGER IN DATABASE!\n";
}
}
}
if ($msg)
{
mail("you@example.com","Featured Products Alert",$msg);
}
?>
Save the above (after editing the email address as required) as scripts/featuredcheck.php and then chain with your existing CRON job. You can normally separate commands in the same CRON job by semi-colon, so if you are currently using:
cd /path/to/scripts;/usr/bin/php cron.php
...you would change to:
cd /path/to/scripts;/usr/bin/php cron.php;/usr/bin/php featuredcheck.php
Cheers!
David
--
PriceTapestry.com
Awesome, David!