besoin d'ajouter l'url du produit dans la contribution XML Export

Archive

Messagepar jb31 » Lun 08 Sep 2008, 21:03

Bonjour, j'ai très peu de connaissance en php, je souhaite ajouter dans le fichier xml que génère la contrib l'url du produit car elle n'est pas présente.
Si qq'un pouvait me dire comment je dois faire, voici le fichier :

<?php
require('includes/application_top.php');

function unhtmlentities($string) {
$trans_tbl = get_html_translation_table (HTML_ENTITIES);
$trans_tbl = array_flip ($trans_tbl);
return strtr ($string, $trans_tbl);
}

$xml_export_filename = 'exportfile'; // default XML filename
$export_folder = 'dataexport'; // folder name that XML files to be created. should be under /catalog/ main folder.


if ($_POST['action']=='export') {

$xml_file='';

function SaveFile($data, $fname = "products"){
global $export_folder;
$filename = DIR_FS_CATALOG . $export_folder . '/' . $fname;

if ($fp = fopen($filename, 'w+')){
fwrite($fp, $data);
fclose($fp);
return true;
}
else return false;
}

function get_categories_ids($parent_id=0) {
$categories=tep_db_query("select categories_id from ".TABLE_CATEGORIES." where parent_id='".$parent_id."'");
while ($category=tep_db_fetch_array($categories)) {
$categories_ids[]=$category['categories_id'];
$current_categories_id = get_categories_ids($category['categories_id']);
if(is_array($current_categories_id)){
$categories_ids=array_merge($categories_ids, $current_categories_id);
}
}
return $categories_ids;
}

$categories_ids[]=$categories_id;

$current_categories_id = get_categories_ids($_POST['categories_id']);
if(is_array($current_categories_id)){
$categories_ids=array_merge($categories_ids, $current_categories_id);
}

$categories_ids = array_filter($categories_ids);

$already_sent = array();

// Varsayýlan CURRENCY nedir bakalým
$query_currency = tep_db_query("SELECT configuration_value FROM " . TABLE_CONFIGURATION . " WHERE configuration_key = 'DEFAULT_CURRENCY'");
$row_currency = tep_db_fetch_array( $query_currency );

// Varsayýlan DÝL nedir bakalým
$query_language_code = tep_db_query("SELECT configuration_value FROM " . TABLE_CONFIGURATION . " WHERE configuration_key = 'DEFAULT_LANGUAGE'");
$row_language_code = tep_db_fetch_array( $query_language_code );

// Varsayýlan DÝL ID nedir bakalým
$query_language_id = tep_db_query("SELECT languages_id FROM " . TABLE_LANGUAGES . " WHERE code = '" . $row_language_code['configuration_value'] . "'");
$row_language_id = tep_db_fetch_array( $query_language_id );

// rün bilgilerini alalým
$products_query = tep_db_query("SELECT
manuf.manufacturers_Name AS manufacturer,
prd.products_id AS id,
prd.products_id AS mpc,
prd.products_model AS model,
prd.products_quantity AS qty,
prdsc.products_Name AS name,
prdsc.products_description AS description,
prd.products_price AS price,
prd.products_image AS image,
prd.products_weight AS weight,
prd.products_status AS status,
prd.products_date_available AS date_available,
prd.products_last_modified AS last_modified,
prd.products_tax_class_id AS tax_id,

catdescparent4.categories_Name AS parent4_cat,
catdescparent3.categories_Name AS parent3_cat,
catdescparent2.categories_Name AS parent2_cat,
catdescparent1.categories_Name AS parent1_cat,
catdesccurrent.categories_Name AS current_cat,

catdescparent4.categories_id AS parent4_id,
catdescparent3.categories_id AS parent3_id,
catdescparent2.categories_id AS parent2_id,
catdescparent1.categories_id AS parent1_id,
catdesccurrent.categories_id AS current_id

FROM (" . TABLE_CATEGORIES . " ,
" . TABLE_PRODUCTS . " prd,
" . TABLE_PRODUCTS_DESCRIPTION . " AS prdsc,
" . TABLE_CATEGORIES_DESCRIPTION . " AS catdesccurrent,
" . TABLE_PRODUCTS_TO_CATEGORIES . " AS prdtocat)

LEFT JOIN " . TABLE_CATEGORIES_DESCRIPTION . " AS catdescparent1 on ( catdescparent1.categories_id = " . TABLE_CATEGORIES . ".parent_id AND catdescparent1.language_id = '" . $row_language_id['languages_id'] . "' )
LEFT JOIN " . TABLE_CATEGORIES . " AS cat2 on ( cat2.categories_id = " . TABLE_CATEGORIES . ".parent_id )
LEFT JOIN " . TABLE_CATEGORIES_DESCRIPTION . " AS catdescparent2 on ( catdescparent2.categories_id = cat2.parent_id AND catdescparent2.language_id = '" . $row_language_id['languages_id'] . "' )
LEFT JOIN " . TABLE_CATEGORIES . " AS cat3 on ( cat3.categories_id = cat2.parent_id )
LEFT JOIN " . TABLE_CATEGORIES_DESCRIPTION . " AS catdescparent3 on ( catdescparent3.categories_id = cat3.parent_id AND catdescparent3.language_id = '" . $row_language_id['languages_id'] . "' )
LEFT JOIN " . TABLE_CATEGORIES . " AS cat4 on ( cat4.categories_id = cat3.parent_id )
LEFT JOIN " . TABLE_CATEGORIES_DESCRIPTION . " AS catdescparent4 on ( catdescparent4.categories_id = cat4.parent_id AND catdescparent4.language_id = '" . $row_language_id['languages_id'] . "' )

LEFT JOIN " . TABLE_MANUFACTURERS . " AS manuf ON ( manuf.manufacturers_id = prd.manufacturers_id )

WHERE
( prd.products_id = prdsc.products_id AND prdsc.language_id = '" . $row_language_id['languages_id'] . "' )
AND prd.products_id = prdtocat.products_id
AND prdtocat.categories_id = " . TABLE_CATEGORIES . ".categories_id
AND ( catdesccurrent.categories_id = " . TABLE_CATEGORIES . ".categories_id AND catdesccurrent.language_id = '" . $row_language_id['languages_id'] . "' )
AND prdtocat.categories_id in (".implode($categories_ids, ', ').")
LIMIT 10000");

// rüne ait özel fiyat varmý bakalým
$specials_query = tep_db_query("SELECT
" . TABLE_SPECIALS . ".products_id AS idS,
FORMAT(" . TABLE_SPECIALS . ".specials_new_products_price, 2) AS priceS
FROM
" . TABLE_SPECIALS . ", " . TABLE_PRODUCTS . "
WHERE
" . TABLE_SPECIALS . ".products_id = " . TABLE_PRODUCTS . ".products_id
AND " . TABLE_SPECIALS . ".status != 0
AND " . TABLE_PRODUCTS . ".products_status != 0");

while( $row_s = tep_db_fetch_array( $specials_query )) foreach ($row_s as $i=>$v) $SPECIALS[$row_s['idS']][$i] = $v;

if (tep_db_num_rows($products_query)) {
$xml_file.="<?xml version="1.0" encoding="windows-1254"?>n";
$xml_file.="<Products>n";

while ($product=tep_db_fetch_array($products_query)) {
// Eðer ayný kodda bir ürün datasý göndermiþsek diðerini artýk göndermeyelim.
if ($already_sent[$product['mpc']] == 1) continue;
// zel fiyatý varsa ürünün onu kullanalým
if( $SPECIALS[$product['id']]['idS'] ) $product['price_special'] = $SPECIALS[$product['id']]['priceS'];
if($product['image']) $product['image_url'] = HTTP_SERVER . DIR_WS_CATALOG . DIR_WS_IMAGES . $product['image'];

$xml_file.="t" . "<Product>n";
if($product['parent4_cat']){
$xml_file.="tt" . "<Main_Category_id>".$product['parent4_id']."</Main_Category_id>n";
$xml_file.="tt" . "<Main_Category_Name>".htmlspecialchars($product['parent4_cat'])."</Main_Category_Name>n";
$xml_file.="tt" . "<Sub_Category_1_id>".$product['parent3_id']."</Sub_Category_1_id>n";
$xml_file.="tt" . "<Sub_Category_1_Name>".htmlspecialchars($product['parent3_cat'])."</Sub_Category_1_Name>n";
$xml_file.="tt" . "<Sub_Category_2_id>".$product['parent2_id']."</Sub_Category_2_id>n";
$xml_file.="tt" . "<Sub_Category_2_Name>".htmlspecialchars($product['parent2_cat'])."</Sub_Category_2_Name>n";
$xml_file.="tt" . "<Sub_Category_3_id>".$product['parent1_id']."</Sub_Category_3_id>n";
$xml_file.="tt" . "<Sub_Category_3_Name>".htmlspecialchars($product['parent1_cat'])."</Sub_Category_3_Name>n";
$xml_file.="tt" . "<Sub_Category_4_id>".$product['current_id']."</Sub_Category_4_id>n";
$xml_file.="tt" . "<Sub_Category_4_Name>".htmlspecialchars($product['current_cat'])."</Sub_Category_4_Name>n";
}
elseif($product['parent3_cat']){
$xml_file.="tt" . "<Main_Category_id>".$product['parent3_id']."</Main_Category_id>n";
$xml_file.="tt" . "<Main_Category_Name>".htmlspecialchars($product['parent3_cat'])."</Main_Category_Name>n";
$xml_file.="tt" . "<Sub_Category_1_id>".$product['parent2_id']."</Sub_Category_1_id>n";
$xml_file.="tt" . "<Sub_Category_1_Name>".htmlspecialchars($product['parent2_cat'])."</Sub_Category_1_Name>n";
$xml_file.="tt" . "<Sub_Category_2_id>".$product['parent1_id']."</Sub_Category_2_id>n";
$xml_file.="tt" . "<Sub_Category_2_Name>".htmlspecialchars($product['parent1_cat'])."</Sub_Category_2_Name>n";
$xml_file.="tt" . "<Sub_Category_3_id>".$product['current_id']."</Sub_Category_3_id>n";
$xml_file.="tt" . "<Sub_Category_3_Name>".htmlspecialchars($product['current_cat'])."</Sub_Category_3_Name>n";
}
elseif($product['parent2_cat']){
$xml_file.="tt" . "<Main_Category_id>".$product['parent2_id']."</Main_Category_id>n";
$xml_file.="tt" . "<Main_Category_Name>".htmlspecialchars($product['parent2_cat'])."</Main_Category_Name>n";
$xml_file.="tt" . "<Sub_Category_1_id>".$product['parent1_id']."</Sub_Category_1_id>n";
$xml_file.="tt" . "<Sub_Category_1_Name>".htmlspecialchars($product['parent1_cat'])."</Sub_Category_1_Name>n";
$xml_file.="tt" . "<Sub_Category_2_id>".$product['current_id']."</Sub_Category_2_id>n";
$xml_file.="tt" . "<Sub_Category_2_Name>".htmlspecialchars($product['current_cat'])."</Sub_Category_2_Name>n";
}
elseif($product['parent1_cat']){
$xml_file.="tt" . "<Main_Category_id>".$product['parent1_id']."</Main_Category_id>n";
$xml_file.="tt" . "<Main_Category_Name>".htmlspecialchars($product['parent1_cat'])."</Main_Category_Name>n";
$xml_file.="tt" . "<Sub_Category_1_id>".$product['current_id']."</Sub_Category_1_id>n";
$xml_file.="tt" . "<Sub_Category_1_Name>".htmlspecialchars($product['current_cat'])."</Sub_Category_1_Name>n";
}
else { // sadece tek kategori altýnda ürün listeleniyorsa !!!
$xml_file.="tt" . "<Main_Category_id>".$product['current_id']."</Main_Category_id>n";
$xml_file.="tt" . "<Main_Category_Name>".htmlspecialchars($product['current_cat'])."</Main_Category_Name>n";
}

$xml_file.="tt" . "<Product_id>".$product['id']."</Product_id>n";
$xml_file.="tt" . "<Product_Model>".htmlspecialchars($product['model'])."</Product_Model>n";
$xml_file.="tt" . "<Product_Name>".htmlspecialchars($product['name'])."</Product_Name>n";
$xml_file.="tt" . "<Product_Description>".htmlspecialchars($product['description'])."</Product_Description>n";
$xml_file.="tt" . "<Product_Price>".number_format($product['price'],2,'.','')."</Product_Price>n";
$xml_file.="tt" . "<Product_Price_Special>".number_format($product['price_special'],2,'.','')."</Product_Price_Special>n";
$xml_file.="tt" . "<Product_Currency>".DEFAULT_CURRENCY."</Product_Currency>n";
$xml_file.="tt" . "<Product_Vat_Rate>".tep_get_tax_rate($product['tax_id'])."</Product_Vat_Rate>n";
$xml_file.="tt" . "<Product_Image>".$product['image']."</Product_Image>n";
$xml_file.="tt" . "<Product_Image_Url>".$product['image_url']."</Product_Image_Url>n";
$xml_file.="tt" . "<Product_Quantity>".$product['qty']."</Product_Quantity>n";
$xml_file.="tt" . "<Product_Weight>".$product['weight']."</Product_Weight>n";
$xml_file.="tt" . "<Product_Status>".$product['status']."</Product_Status>n";
$xml_file.="tt" . "<Product_Manufacturer>".$product['manufacturer']."</Product_Manufacturer>n";
$xml_file.="tt" . "<Product_Last_Modified>".$product['last_modified']."</Product_Last_Modified>n";
$xml_file.="tt" . "<Product_Date_Available>".$product['date_available']."</Product_Date_Available>n";
$xml_file.="t" . "</Product>n";

$already_sent[$product['mpc']] = 1;
}
$xml_file.="</Products>n";
}

switch ($_POST['XML_archive']) {
case 'xml': $ext='.xml';
break;
case 'zip': $ext='.xml.zip';
$zipfile = new zipfile();
$zipfile->addFile($xml_file, $_POST['filename'].'.xml');
$xml_file=$zipfile->file();
break;
case 'gzip':$ext='.xml.gz';
$xml_file=gzencode($xml_file);
break;
}

if ($_POST['download']){
header("Content-Type: application/octetstream");
header("Content-Disposition: attachment; filename=".$_POST['filename'].$ext);
header("Content-Length: ".strlen($xml_file));
header("Expires: 0");
echo $xml_file;
exit();
}
else {
if(SaveFile($xml_file, $_POST['filename'].$ext) == 'false') echo 'XML file successfully created..';
else echo 'XML file not created..';
exit();
}
}
?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
</head>
<body>

<table border="1" width="100%" cellspacing="0" cellpadding="2">
<tr bgcolor="#CCCCCC">
<td colspan="2"><strong>Snowbird/Expert osC XML Export</strong></td>
</tr>
<tr>
<td>Select Category</td>
<td class="main">
<?php echo tep_draw_form('xml-export', basename($_SERVER['PHP_SELF']), '', 'post') ."n". tep_draw_pull_down_menu('categories_id', tep_get_category_tree(), $categories_id) ."n"; ?>
<input type="hidden" name="action" value="export">
</td>
</tr>
<tr>
<td>File Type and Name (without extention)</td>
<td>
<select name="XML_archive">
<option value="xml">Plain XML</option>
<?php if (@function_exists('gzcompress')) { ?>
<option value="zip">ZIP'ped XML</option>
<?php } if (@function_exists('gzencode')) { ?>
<option value="gzip">GZIP'ped XML</option>
<?php } ?>
</select>
<input type="text" name="filename" value="<?php echo $xml_export_filename; ?>">
<input name="download" type="checkbox" value="ON">&nbsp;Download
</td>
<tr>
<td colspan="2"><input type="submit" value="<--Go-->"></form></td>
</tr>
</table>
</body>
</html>
jb31
Membre très actif
 
Messages: 164
Inscription: Ven 29 Aoû 2008, 18:27

Messagepar jb31 » Mar 09 Sep 2008, 10:48

bonjour, il n'y a personne qui aurait déjà fait ça sur ce code?
J'en ai vraiment besoin car peu de contrib d'export catalogue marche sur mon site...
Merci d'avance!
jb31
Membre très actif
 
Messages: 164
Inscription: Ven 29 Aoû 2008, 18:27

Messagepar cynic- » Mar 09 Sep 2008, 13:15

Je n'ai pas lu ton ((très) long) code, mais pour ce type de demande, je te conseille Easy Populate qui gère les url (entre autres : name, description, url, image, attributes, categories, manufacturer, price, quantity, weight, tax class, available, date added, status) en import ET en export
Je n'ai jamais utilisé XML Export :(

Au fait, pense à ajouter les balises {code} {/code} pour faciliter la lecture, et donc l'aide ;) Remplace les accolades par des crochets [ ]
cynic-
Site Admin
 
Messages: 694
Inscription: Mar 04 Déc 2007, 13:04

Messagepar jb31 » Mar 09 Sep 2008, 13:23

ha oui, merci donc voici le code :

(A noter dans le code ci joint, j'ai ajouté "prdsc.products_url AS url", et " $xml_file.="tt" . "<Product_Url>".$product['url']."</Product_Url>n";")
MERCI, je pense que c'est assez simple mais pour quelqu'un qui connait moi je ne peux qu'y arriver après de longues heures fastidieuse...

Code: Tout sélectionner
<?php
require('includes/application_top.php');

function unhtmlentities($string) {
  $trans_tbl = get_html_translation_table (HTML_ENTITIES);
  $trans_tbl = array_flip ($trans_tbl);
  return strtr ($string, $trans_tbl);
}

$xml_export_filename = 'exportfile';  // default XML filename
$export_folder = 'dataexport';  // folder name that XML files to be created. should be under /catalog/ main folder.


if ($_POST['action']=='export') {

  $xml_file='';

  function SaveFile($data, $fname = "products"){
        global $export_folder;
        $filename  = DIR_FS_CATALOG . $export_folder . '/' . $fname;

        if ($fp = fopen($filename, 'w+')){
                fwrite($fp, $data);
                fclose($fp);
                return true;
        }
        else  return false;
  }

  function get_categories_ids($parent_id=0) {
    $categories=tep_db_query("select categories_id from ".TABLE_CATEGORIES." where parent_id='".$parent_id."'");
    while ($category=tep_db_fetch_array($categories)) {
      $categories_ids[]=$category['categories_id'];
   $current_categories_id = get_categories_ids($category['categories_id']);
    if(is_array($current_categories_id)){
     $categories_ids=array_merge($categories_ids, $current_categories_id);
   }
    }
    return $categories_ids;
  }

  $categories_ids[]=$categories_id;

  $current_categories_id = get_categories_ids($_POST['categories_id']);
  if(is_array($current_categories_id)){
   $categories_ids=array_merge($categories_ids, $current_categories_id);
  }

  $categories_ids = array_filter($categories_ids);

$already_sent = array();

// Varsayýlan CURRENCY nedir bakalým
$query_currency = tep_db_query("SELECT configuration_value FROM " . TABLE_CONFIGURATION . " WHERE configuration_key = 'DEFAULT_CURRENCY'");
$row_currency = tep_db_fetch_array( $query_currency );

// Varsayýlan DÝL nedir bakalým
$query_language_code = tep_db_query("SELECT configuration_value FROM " . TABLE_CONFIGURATION . " WHERE configuration_key = 'DEFAULT_LANGUAGE'");
$row_language_code = tep_db_fetch_array( $query_language_code );

// Varsayýlan DÝL ID nedir bakalým
$query_language_id = tep_db_query("SELECT languages_id FROM " . TABLE_LANGUAGES . " WHERE code = '" . $row_language_code['configuration_value'] . "'");
$row_language_id = tep_db_fetch_array( $query_language_id );

// rün bilgilerini alalým
$products_query = tep_db_query("SELECT
manuf.manufacturers_Name AS manufacturer,
prd.products_id AS id,
prd.products_id AS mpc,
prd.products_model AS model,
prd.products_quantity AS qty,
prdsc.products_Name AS name,
prdsc.products_description AS description,
prdsc.products_url AS url,
prd.products_price AS price,
prd.products_image AS image,
prd.products_weight AS weight,
prd.products_status AS status,
prd.products_date_available AS date_available,
prd.products_last_modified AS last_modified,
prd.products_tax_class_id AS tax_id,

catdescparent4.categories_Name AS parent4_cat,
catdescparent3.categories_Name AS parent3_cat,
catdescparent2.categories_Name AS parent2_cat,
catdescparent1.categories_Name AS parent1_cat,
catdesccurrent.categories_Name AS current_cat,

catdescparent4.categories_id AS parent4_id,
catdescparent3.categories_id AS parent3_id,
catdescparent2.categories_id AS parent2_id,
catdescparent1.categories_id AS parent1_id,
catdesccurrent.categories_id AS current_id

FROM (" . TABLE_CATEGORIES . " ,
" . TABLE_PRODUCTS . " prd,
" . TABLE_PRODUCTS_DESCRIPTION . " AS prdsc,
" . TABLE_CATEGORIES_DESCRIPTION . " AS catdesccurrent,
" . TABLE_PRODUCTS_TO_CATEGORIES . " AS prdtocat)

LEFT JOIN " . TABLE_CATEGORIES_DESCRIPTION . " AS catdescparent1 on ( catdescparent1.categories_id = " . TABLE_CATEGORIES . ".parent_id AND catdescparent1.language_id = '" . $row_language_id['languages_id'] . "' )
LEFT JOIN " . TABLE_CATEGORIES . " AS cat2 on ( cat2.categories_id = " . TABLE_CATEGORIES . ".parent_id )
LEFT JOIN " . TABLE_CATEGORIES_DESCRIPTION . " AS catdescparent2 on ( catdescparent2.categories_id = cat2.parent_id AND catdescparent2.language_id = '" . $row_language_id['languages_id'] . "' )
LEFT JOIN " . TABLE_CATEGORIES . " AS cat3 on ( cat3.categories_id = cat2.parent_id )
LEFT JOIN " . TABLE_CATEGORIES_DESCRIPTION . " AS catdescparent3 on ( catdescparent3.categories_id = cat3.parent_id AND catdescparent3.language_id = '" . $row_language_id['languages_id'] . "' )
LEFT JOIN " . TABLE_CATEGORIES . " AS cat4 on ( cat4.categories_id = cat3.parent_id )
LEFT JOIN " . TABLE_CATEGORIES_DESCRIPTION . " AS catdescparent4 on ( catdescparent4.categories_id = cat4.parent_id AND catdescparent4.language_id = '" . $row_language_id['languages_id'] . "' )

LEFT JOIN " . TABLE_MANUFACTURERS . " AS manuf ON ( manuf.manufacturers_id = prd.manufacturers_id )

WHERE
( prd.products_id = prdsc.products_id AND prdsc.language_id = '" . $row_language_id['languages_id'] . "' )
AND prd.products_id = prdtocat.products_id
AND prdtocat.categories_id = " . TABLE_CATEGORIES . ".categories_id
AND ( catdesccurrent.categories_id = " . TABLE_CATEGORIES . ".categories_id AND catdesccurrent.language_id = '" . $row_language_id['languages_id'] . "' )
AND prdtocat.categories_id in (".implode($categories_ids, ', ').")
LIMIT 10000");

// rüne ait özel fiyat varmý bakalým
$specials_query = tep_db_query("SELECT
" . TABLE_SPECIALS . ".products_id AS idS,
FORMAT(" . TABLE_SPECIALS . ".specials_new_products_price, 2) AS priceS
FROM
" . TABLE_SPECIALS . ", " . TABLE_PRODUCTS . "
WHERE
" . TABLE_SPECIALS . ".products_id = " . TABLE_PRODUCTS . ".products_id
AND " . TABLE_SPECIALS . ".status != 0
AND " . TABLE_PRODUCTS . ".products_status != 0");

while( $row_s = tep_db_fetch_array( $specials_query )) foreach ($row_s as $i=>$v) $SPECIALS[$row_s['idS']][$i] = $v;

  if (tep_db_num_rows($products_query)) {
    $xml_file.="<?xml version="1.0" encoding="windows-1254"?>n";
    $xml_file.="<Products>n";

    while ($product=tep_db_fetch_array($products_query)) {
  // Eðer ayný kodda bir ürün datasý göndermiþsek diðerini artýk göndermeyelim.
 if ($already_sent[$product['mpc']] == 1) continue;
    // zel fiyatý varsa ürünün onu kullanalým
 if( $SPECIALS[$product['id']]['idS'] ) $product['price_special'] = $SPECIALS[$product['id']]['priceS'];
 if($product['image']) $product['image_url'] = HTTP_SERVER . DIR_WS_CATALOG . DIR_WS_IMAGES . $product['image'];

      $xml_file.="t" . "<Product>n";
if($product['parent4_cat']){
      $xml_file.="tt" . "<Main_Category_id>".$product['parent4_id']."</Main_Category_id>n";
    $xml_file.="tt" . "<Main_Category_Name>".htmlspecialchars($product['parent4_cat'])."</Main_Category_Name>n";
      $xml_file.="tt" . "<Sub_Category_1_id>".$product['parent3_id']."</Sub_Category_1_id>n";
   $xml_file.="tt" . "<Sub_Category_1_Name>".htmlspecialchars($product['parent3_cat'])."</Sub_Category_1_Name>n";
      $xml_file.="tt" . "<Sub_Category_2_id>".$product['parent2_id']."</Sub_Category_2_id>n";
      $xml_file.="tt" . "<Sub_Category_2_Name>".htmlspecialchars($product['parent2_cat'])."</Sub_Category_2_Name>n";
      $xml_file.="tt" . "<Sub_Category_3_id>".$product['parent1_id']."</Sub_Category_3_id>n";
      $xml_file.="tt" . "<Sub_Category_3_Name>".htmlspecialchars($product['parent1_cat'])."</Sub_Category_3_Name>n";
      $xml_file.="tt" . "<Sub_Category_4_id>".$product['current_id']."</Sub_Category_4_id>n";
      $xml_file.="tt" . "<Sub_Category_4_Name>".htmlspecialchars($product['current_cat'])."</Sub_Category_4_Name>n";
}
elseif($product['parent3_cat']){
      $xml_file.="tt" . "<Main_Category_id>".$product['parent3_id']."</Main_Category_id>n";
   $xml_file.="tt" . "<Main_Category_Name>".htmlspecialchars($product['parent3_cat'])."</Main_Category_Name>n";
      $xml_file.="tt" . "<Sub_Category_1_id>".$product['parent2_id']."</Sub_Category_1_id>n";
   $xml_file.="tt" . "<Sub_Category_1_Name>".htmlspecialchars($product['parent2_cat'])."</Sub_Category_1_Name>n";
      $xml_file.="tt" . "<Sub_Category_2_id>".$product['parent1_id']."</Sub_Category_2_id>n";
      $xml_file.="tt" . "<Sub_Category_2_Name>".htmlspecialchars($product['parent1_cat'])."</Sub_Category_2_Name>n";
      $xml_file.="tt" . "<Sub_Category_3_id>".$product['current_id']."</Sub_Category_3_id>n";
      $xml_file.="tt" . "<Sub_Category_3_Name>".htmlspecialchars($product['current_cat'])."</Sub_Category_3_Name>n";
}
elseif($product['parent2_cat']){
      $xml_file.="tt" . "<Main_Category_id>".$product['parent2_id']."</Main_Category_id>n";
    $xml_file.="tt" . "<Main_Category_Name>".htmlspecialchars($product['parent2_cat'])."</Main_Category_Name>n";
      $xml_file.="tt" . "<Sub_Category_1_id>".$product['parent1_id']."</Sub_Category_1_id>n";
   $xml_file.="tt" . "<Sub_Category_1_Name>".htmlspecialchars($product['parent1_cat'])."</Sub_Category_1_Name>n";
      $xml_file.="tt" . "<Sub_Category_2_id>".$product['current_id']."</Sub_Category_2_id>n";
      $xml_file.="tt" . "<Sub_Category_2_Name>".htmlspecialchars($product['current_cat'])."</Sub_Category_2_Name>n";
}
elseif($product['parent1_cat']){
      $xml_file.="tt" . "<Main_Category_id>".$product['parent1_id']."</Main_Category_id>n";
   $xml_file.="tt" . "<Main_Category_Name>".htmlspecialchars($product['parent1_cat'])."</Main_Category_Name>n";
      $xml_file.="tt" . "<Sub_Category_1_id>".$product['current_id']."</Sub_Category_1_id>n";
      $xml_file.="tt" . "<Sub_Category_1_Name>".htmlspecialchars($product['current_cat'])."</Sub_Category_1_Name>n";
}
else { // sadece tek kategori altýnda ürün listeleniyorsa !!!
      $xml_file.="tt" . "<Main_Category_id>".$product['current_id']."</Main_Category_id>n";
    $xml_file.="tt" . "<Main_Category_Name>".htmlspecialchars($product['current_cat'])."</Main_Category_Name>n";
}

      $xml_file.="tt" . "<Product_id>".$product['id']."</Product_id>n";
      $xml_file.="tt" . "<Product_Model>".htmlspecialchars($product['model'])."</Product_Model>n";
      $xml_file.="tt" . "<Product_Name>".htmlspecialchars($product['name'])."</Product_Name>n";
      $xml_file.="tt" . "<Product_Description>".htmlspecialchars($product['description'])."</Product_Description>n";
   $xml_file.="tt" . "<Product_Url>".$product['url']."</Product_Url>n";
      $xml_file.="tt" . "<Product_Price>".number_format($product['price'],2,'.','')."</Product_Price>n";
      $xml_file.="tt" . "<Product_Price_Special>".number_format($product['price_special'],2,'.','')."</Product_Price_Special>n";
      $xml_file.="tt" . "<Product_Currency>".DEFAULT_CURRENCY."</Product_Currency>n";
      $xml_file.="tt" . "<Product_Vat_Rate>".tep_get_tax_rate($product['tax_id'])."</Product_Vat_Rate>n";
      $xml_file.="tt" . "<Product_Image>".$product['image']."</Product_Image>n";
      $xml_file.="tt" . "<Product_Image_Url>".$product['image_url']."</Product_Image_Url>n";
      $xml_file.="tt" . "<Product_Quantity>".$product['qty']."</Product_Quantity>n";
      $xml_file.="tt" . "<Product_Weight>".$product['weight']."</Product_Weight>n";
      $xml_file.="tt" . "<Product_Status>".$product['status']."</Product_Status>n";
      $xml_file.="tt" . "<Product_Manufacturer>".$product['manufacturer']."</Product_Manufacturer>n";
      $xml_file.="tt" . "<Product_Last_Modified>".$product['last_modified']."</Product_Last_Modified>n";
      $xml_file.="tt" . "<Product_Date_Available>".$product['date_available']."</Product_Date_Available>n";
      $xml_file.="t" .   "</Product>n";

      $already_sent[$product['mpc']] = 1;
    }
    $xml_file.="</Products>n";
  }

  switch ($_POST['XML_archive']) {
    case 'xml': $ext='.xml';
                break;
    case 'zip': $ext='.xml.zip';
                $zipfile = new zipfile();
                $zipfile->addFile($xml_file, $_POST['filename'].'.xml');
                $xml_file=$zipfile->file();
                break;
    case 'gzip':$ext='.xml.gz';
                $xml_file=gzencode($xml_file);
                break;
  }

  if ($_POST['download']){
    header("Content-Type: application/octetstream");
    header("Content-Disposition: attachment; filename=".$_POST['filename'].$ext);
   header("Content-Length: ".strlen($xml_file));
   header("Expires: 0");
   echo $xml_file;
   exit();
 }
 else {
    if(SaveFile($xml_file, $_POST['filename'].$ext) == 'false') echo 'XML file successfully created..';
    else echo 'XML file not created..';
    exit();
 }
}
?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
</head>
<body>

<table border="1" width="100%" cellspacing="0" cellpadding="2">
      <tr bgcolor="#CCCCCC">
        <td colspan="2"><strong>Snowbird/Expert osC XML Export</strong></td>
      </tr>
      <tr>
        <td>Select Category</td>
        <td class="main">
          <?php echo tep_draw_form('xml-export', basename($_SERVER['PHP_SELF']), '', 'post') ."n". tep_draw_pull_down_menu('categories_id', tep_get_category_tree(), $categories_id) ."n"; ?>
         <input type="hidden" name="action" value="export">
        </td>
       </tr>
       <tr>
          <td>File Type and Name (without extention)</td>
           <td>
            <select name="XML_archive">
             <option value="xml">Plain XML</option>
            <?php if (@function_exists('gzcompress')) { ?>
              <option value="zip">ZIP'ped XML</option>
            <?php } if (@function_exists('gzencode')) { ?>
             <option value="gzip">GZIP'ped XML</option>
            <?php } ?>
            </select>
          <input type="text" name="filename" value="<?php echo $xml_export_filename; ?>">
         <input name="download" type="checkbox" value="ON">&nbsp;Download
            </td>
       <tr>
            <td colspan="2"><input type="submit" value="<--Go-->"></form></td>
      </tr>
</table>
</body>
</html>

Pour easy populate, je vais voir si ça colle avec mon site, cette contrib m'intéresse car elle est tellement simple (seulement un fichier à rajouter et 2-3 modif, presque rien) que j'aimerai qd mm trouver une solution. D'autant plus que le fichier est parfait sauf qu'il n'y a pas les urls produits.
jb31
Membre très actif
 
Messages: 164
Inscription: Ven 29 Aoû 2008, 18:27

Messagepar jb31 » Mar 09 Sep 2008, 14:00

est ce que qq un pourrait me dire ou sont stockées les urls dans les tables de la db? Si elles y sont stockées car je ne les voient ni dans products_url ni dans products_seo_url...
Merci.
jb31
Membre très actif
 
Messages: 164
Inscription: Ven 29 Aoû 2008, 18:27

Messagepar j4k » Mar 09 Sep 2008, 14:13

les url ne sont pas stockées dans la bd, il y a une fonction dans html_output qui crée les urls lorsque tu les appelle.

cette fonction s'appele comme ceci :

Code: Tout sélectionner
 tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $product['id'])

par conter vu que ton fichier est appellé depuis l'admin, il va te créer un lien vers la page coté admin...

une solution simple (mais sans ré-écriture SEO) est de mettre directement ceci :
Code: Tout sélectionner
      $xml_file.="tt" . "<Product_link>" .HTTP_SERVER . DIR_WS_HTTP_CATALOG . 'product_info.php?products_id=' . $product['id'] . "</Product_link>n";

pour mettre le lien avec SEO, il faut insérer la fonction tep_href_link de catalog>include>functions>html_output.php en la renommant (pour éviter le conflit avec la même foncion de l'admin) et appeler ton lien avec le première méthode
~ osCSS 1.2.1 ~
Avatar de l’utilisateur
j4k
Site Admin
 
Messages: 1259
Inscription: Mer 27 Avr 2005, 09:13
Localisation: France

Messagepar jb31 » Mar 09 Sep 2008, 14:23

Je te remercie énormément, ça fonctionne!
Chapeau bas!
jb31
Membre très actif
 
Messages: 164
Inscription: Ven 29 Aoû 2008, 18:27

Messagepar j4k » Mar 09 Sep 2008, 14:28

oncernant le lien $url que tu récupère dans la bdd, il s'agit du lien vers le site du constructeur que tu peut saisir dans la fiche produit

Code: Tout sélectionner
$xml_file.="tt" . "<Product_Url>".$product['url']."</Product_Url>n";")
~ osCSS 1.2.1 ~
Avatar de l’utilisateur
j4k
Site Admin
 
Messages: 1259
Inscription: Mer 27 Avr 2005, 09:13
Localisation: France

Messagepar jb31 » Mar 09 Sep 2008, 15:08

En faite je ne récupère aucun lien de la bdd car je n'y ai pas d'urls inscrites, par contre j'ai une autre question concernant mon fichier xml, je souhaite y ajouter des délais de livraisons par défauts. Pourrais tu me dire comment je dois faire?
jb31
Membre très actif
 
Messages: 164
Inscription: Ven 29 Aoû 2008, 18:27

Messagepar j4k » Mar 09 Sep 2008, 15:23

les délais que tu souhaite aficher sont stockés ou ? dans la bdd ? ils sont identiques pour chaque produits ?
~ osCSS 1.2.1 ~
Avatar de l’utilisateur
j4k
Site Admin
 
Messages: 1259
Inscription: Mer 27 Avr 2005, 09:13
Localisation: France

Messagepar jb31 » Mar 09 Sep 2008, 15:42

Oui, ils sont tous identique.
Sinon je crois que je vais devoir intégrer un nouvel attribut produit pour pouvoir gérer les délais de livraisons et les garantie aussi pour l'occasion et neuf...
jb31
Membre très actif
 
Messages: 164
Inscription: Ven 29 Aoû 2008, 18:27

Messagepar j4k » Mar 09 Sep 2008, 15:44

ben tu peut alors le mettre en dur dans le fichier xml !
~ osCSS 1.2.1 ~
Avatar de l’utilisateur
j4k
Site Admin
 
Messages: 1259
Inscription: Mer 27 Avr 2005, 09:13
Localisation: France

Messagepar jb31 » Mar 09 Sep 2008, 16:19

ha oui, pour les délais de livraison c'ets vrai que je peux faire ça...
ho lieu de mettre par exemple [image] dans :
Code: Tout sélectionner
 $xml_file.="tt" . "<Product_Image>".$product['image']."</Product_Image>n";

je mets en dur 2 à 3 jours? C'est ça?
En faite je ne sais pas, j'ai pas essayé encore, mais il me semble qu'il faut faire un rapprochement à une table de la db au début du fichier et mettre le chemin à la fin comme tu m'as indiqué tout à l'heure. Donc vu que je n'ai pas de table gérant les délais je ne sais pas comment faire... Mais peut être j'en serais plus une fois que j'aurais essayé, si tu peux éclairer ma lanterne, en tout cas, je te remercie...
jb31
Membre très actif
 
Messages: 164
Inscription: Ven 29 Aoû 2008, 18:27

Messagepar j4k » Mar 09 Sep 2008, 16:32

ben si tu n'a pas besoins de les rentrer dans la bdd pour autre chose tu peux mettre :

Code: Tout sélectionner
 $xml_file.="tt" . "<Product_Shipping>2 à 3 jours</Product_shipping>n";
~ osCSS 1.2.1 ~
Avatar de l’utilisateur
j4k
Site Admin
 
Messages: 1259
Inscription: Mer 27 Avr 2005, 09:13
Localisation: France

Messagepar jb31 » Mar 09 Sep 2008, 16:36

Ok, super je vais faire ça, je te remercie pour tout car ton aide m'a été vraiment précieuse!
jb31
Membre très actif
 
Messages: 164
Inscription: Ven 29 Aoû 2008, 18:27


Retourner vers osCSS 1.2

 


  • Articles en relation
    Réponses
    Vus
    Dernier message

Qui est en ligne

Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 2 invités

cron