Pagina 1 di 1

aiuto trovaprezzi

Inviato: 23/02/2006, 10:42
da fielpo
salve atutti volevo mettere il mio sito su trovaprezzi, lo script che mi mandano loro nn mi funziona, ma mi funziona uno creato da bass...solo che loro mi chiedono di inserire in un prodotto tutte le categorie madri...es
hardware--->cpu--->intele--->pentium4.....

e siccome io di php non son una mazza...spero in un vostro aiuto..denghiu...vi posto il codice..

//QUANDO EFFETTUATE MODIFICHE AL VOSTRO CATALOGO LANCIATE QUESTO FILE CHE VA MESSO NELLA CARTELLA PRINCIPALE DI OSCOMMERCE
//IMPOSTATE I PERMESSI A 777 PER ENTRAMBI I FILES, HO ACCLUSO ANCHE IL FILE MONDOPREZZI.TXT IN CASO NON VENGA GENERAATO IN AUTOMATICO

include('includes/application_top.php');

require(DIR_WS_INCLUDES . 'database_tables.php');


function get_special_price($product_id) {
$special_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$product_id . "' and status");
$special = tep_db_fetch_array($special_query);
return $special['specials_new_products_price'];
}

//INSERIRE QUI IL NOME DEL FILE DA GENERARE
$nomefile = '/trovaprezzi.txt';

// INSERIRE QUI IL NOME DEL SITO! IMPORTANTE: SENZA SLASH FINALE!
$site_url = "http://www.fcmediastore.com";

// INSERIRE QUI L'ID DELLA LINGUA CHE SI VUOLE USARE
// NORMALMENTE L'ITALIANO HA VALORE 4, CONTROLLARE COMUNQUE DA PHPMYADMIN
$language_id = "4";

$var=fopen(DIR_FS_CATALOG . $nomefile,'w');

$products_query_raw = "select p.products_id, pd.products_name, pd.products_description, p.products_image, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, p.products_quantity, cd.categories_name, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on p.products_id=p2c.products_id left join " . TABLE_CATEGORIES . " c on p2c.categories_id=c.categories_id left join " . TABLE_CATEGORIES_DESCRIPTION . " cd on c.parent_id='0' and c.categories_id=cd.categories_id left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' and cd.language_id = '" . $languages_id . "' order by cd.categories_name, c.parent_id, c.sort_order, c.categories_id, pd.products_name";
$products_query = tep_db_query($products_query_raw);


while ($products = tep_db_fetch_array($products_query)) {

$descrizionehtml=$products["products_description"];

$descrizionehtml=strip_tags($descrizionehtml);
$descrizionehtml=substr($descrizionehtml,0,255);


// $document contiene un documento HTML.
// In questo esempio la funzione rimuove i tag HTML,
// le sezioni javascript e gli spazi bianchi.
// Inoltre si convertirà le entità HTML nella loro
// rappresentazione testuale.
$search = array ("'<script[^>]*?>.*?</script>'si", // Rimozione del javascript
"'<[\/\!]*?[^<>]*?>'si", // Rimozione dei tag HTML
"'([\r\n])[\s]+'", // Rimozione degli spazi bianchi
"'([\r])+'", // Rimozione degli spazi bianchi
"'([\n])+'", // Rimozione degli spazi bianchi
"'&(quot|#34);'i", // Sostituzione delle entità HTML
"'&(amp|#38);'i",
"'&(lt|#60);'i",
"'&(gt|#62);'i",
"'&(nbsp|#160);'i",
"'&(iexcl|#161);'i",
"'&(cent|#162);'i",
"'&(pound|#163);'i",
"'&(copy|#169);'i",
"'&#(\d+);'e"); // Valuta come codice PHP

$replace = array ("",
"",
"",
"",
"",
"",
"",
"",
"",
"",
chr(161),
chr(162),
chr(163),
chr(169),
"chr(\\1)");

$description = preg_replace($search, $replace, $descrizionehtml);

$prezzo=$products['products_price'];
if ($newprice = get_special_price($products['products_id'])) {
$prezzo=$products['specials_new_products_price'];
}

$calcolo_tasse_query = tep_db_query("select tax_rate from " . TABLE_TAX_RATES . " where tax_class_id = '".(int)$products["products_tax_class_id"]."'");
$calcolo_tasse = tep_db_fetch_array($calcolo_tasse_query);
$valore_tassa = ($prezzo/100)* ($calcolo_tasse['tax_rate']);
$prezzo= tep_round($prezzo + $valore_tassa, 2);

if ($products['products_quantity'] > 0){
$disponibile= 'disponibile';
} else {
$disponibile= 'non disponibile';
}
$categoria=$products["categories_name"];
If ($categoria!="Regali Punti Spesa" && $categoria!="Semi di Fiori - Annuali/Biennali" && $categoria!="Semi di Fiori - Perenni" ){ // Qui è possibile inserire una categoria da non esportare!

//Recupera la categoria madre
$result1 = tep_db_query("SELECT categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '".(int)$products['parent_id']."' and language_id = '".(int)$language_id."'" );
$products1= tep_db_fetch_array($result1);
if ($products['categories_id']== 0) {
$stringa_categorie = $categoria;
} else {
$stringa_categorie = $products1['categories_name'] . ';' . $categoria;
}

$filestring.=$row["products_id"]."|".$row["products_name"]."|".$site_url."/images/".$row["products_image"]."|".$site_url."/product_info.php?products_id=".$row["products_id"]."|".$cat_list."|".$row["final_price"]."|".$descrizione1."|".$row["marca"]."<endrecord>\r\n";
fwrite($var, $filestring);
echo $filestring;

}


}

fclose($var);

?>