PDA

View Full Version : Report Missing and Unassignes Images



michael_s
07-23-2007, 09:32 AM
a function which can also be bundled with these and removes duplicate images for categories
the file is just this function......

/************************************
*Functions * find and delete duplicate pictures from the database
************************************/

function goFindDuplicates() {
$image_query = tep_db_query("select products_id, products_image, products_subimage1, products_subimage2, products_subimage3,products_subimage4,products_sub image5,products_subimage6,products_subimage7,produ cts_subimage8, products_subimage9 from products order by products_id ");
$m = array("0","1","2","3","4","5","6","7","8","9"); // original array, all different
$m2 = array("products_image","products_subimage1","products_subimage2","products_subimage3","products_subimage4","products_subimage5","products_subimage6","products_subimage7","products_subimage8","products_subimage9"); // original array, all different
$index = 1;
while ( $m= tep_db_fetch_array($image_query)) {
$xa[0]=$m['products_image'];
if ($m['products_subimage1'] != '') $xa[1]=$m['products_subimage1'];
if ($m['products_subimage2'] != '') $xa[2]=$m['products_subimage2'];
if ($m['products_subimage3'] != '') $xa[3]=$m['products_subimage3'];
if ($m['products_subimage4'] != '') $xa[4]=$m['products_subimage4'];
if ($m['products_subimage5'] != '') $xa[5]=$m['products_subimage5'];
if ($m['products_subimage6'] != '') $xa[6]=$m['products_subimage6'];
if ($m['products_subimage7'] != '') $xa[7]=$m['products_subimage7'];
if ($m['products_subimage8'] != '') $xa[8]=$m['products_subimage8'];
if ($m['products_subimage9'] != '') $xa[9]=$m['products_subimage9'];
$uniqueArray = array_unique($xa);//only unique values
$dupArray = array_diff_assoc($xa, $uniqueArray);//duplicated values
foreach ($dupArray as $value) {
//do whatever you want here like build an assoc array.
$index = array_search($value,$xa) ;
if ($index == 0) { $xa[0]= 'ax'; // hose
$index = array_search($value,$xa); // reset
}
// echo $m['products_id'] . ", duplicate value='$value' @ " . $m2[$index] . "
";
// echo "update products set " . $m2[$index] . " = '' where products_id = " . $m['products_id'] . '
';
tep_db_query("update products set " . $m2[$index] . " = '' where products_id = " . $m['products_id'] );
}
}
}



More... (http://www.oscommerce.com/community/contributions,4503)