Jump to content
xt:Commerce Community Forum

Froogle Export Fertig


Haxley

Recommended Posts

Der Code f?r den Froogle Export ist fertig m??te auch funzn.

Bitte mal testen!

Gru? Haxley

Wie man den einbindet weiss ja wohl jeder... loool, erz?hl ich jetzt nicht.


<?php

/* -----------------------------------------------------------------------------------------

  $Id: froogle.php,v 0.2 2004/12/17 21:45:10 Haxley Exp $


  XT-Commerce - community made shopping

  http://www.xt-commerce.com


  Copyright (c) 2004 XT-Commerce

  -----------------------------------------------------------------------------------------

  based on:

  (c) 2000-2001 The Exchange Project (earlier name of osCommerce)

  (c) 2002-2003 osCommerce(cod.php,v 1.28 2003/02/14); [url]www.oscommerce.com[/url]

  (c) 2003 nextcommerce (invoice.php,v 1.6 2003/08/24); [url]www.nextcommerce.org[/url]


  Released under the GNU General Public License


 Modified for XT-Commerce by Haxley (froogle.php,v 0.2)

 http://www.plexcom.de

 Dez , 2004

  ---------------------------------------------------------------------------------------*/



define('MODULE_FROOGLE_TEXT_DESCRIPTION', 'Export - Froogle im txt Format');

define('MODULE_FROOGLE_TEXT_TITLE', 'Froogle - txt');

define('MODULE_FROOGLE_FILE_TITLE' , '<hr noshade>Dateiname');

define('MODULE_FROOGLE_FILE_DESC' , 'Geben Sie einen Dateinamen ein, falls die Exportadatei am Server gespeichert werden soll.<br>(Verzeichnis export/)');

define('MODULE_FROOGLE_STATUS_DESC','Modulstatus');

define('MODULE_FROOGLE_STATUS_TITLE','Status');

define('MODULE_FROOGLE_CURRENCY_TITLE','W?hrung');

define('MODULE_FROOGLE_CURRENCY_DESC','Welche W?hrung soll exportiert werden?');

define('EXPORT_YES','Nur Herunterladen');

define('EXPORT_NO','Am Server Speichern');

define('CURRENCY','<hr noshade><b>W?hrung:</b>');

define('CURRENCY_DESC','W?hrung in der Exportdatei');

define('EXPORT','Bitte den Sicherungsprozess AUF KEINEN FALL unterbrechen. Dieser kann einige Minuten in Anspruch nehmen.');

define('EXPORT_TYPE','<hr noshade><b>Speicherart:</b>');

define('EXPORT_STATUS_TYPE','<hr noshade><b>Kundengruppe:</b>');

define('EXPORT_STATUS','Bitte w?hlen Sie die Kundengruppe, die Basis f?r den Exportierten Preis bildet. (Falls Sie keine Kundengruppenpreise haben, w?hlen Sie <i>Gast</i>):</b>');

define('CHARSET','iso-8859-1');


// include needed functions


 class froogle {

  var $code, $title, $description, $enabled;



  function froogle() {

   global $order;


   $this->code = 'froogle';

   $this->title = MODULE_FROOGLE_TEXT_TITLE;

   $this->description = MODULE_FROOGLE_TEXT_DESCRIPTION;

   $this->sort_order = MODULE_FROOGLE_SORT_ORDER;

   $this->enabled = ((MODULE_FROOGLE_STATUS == 'True') ? true : false);


  }



  function process($file) {


    @xtc_set_time_limit(0);



    $schema .= 'product_url'."\t".'name'."\t".'description'."\t".'image_url'."\t".'category'."\t".'price'."\n";



    $export_query =xtc_db_query("SELECT

               p.products_id,

               pd.products_name,

               pd.products_description,

    p.products_image,

    p.products_discount_allowed,

    p.products_price,

               p.products_model,

               p.products_date_added,

               m.manufacturers_name

             FROM

               " . TABLE_PRODUCTS . " p 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 = '".$_SESSION['languages_id']."' LEFT JOIN

               " . TABLE_SPECIALS . " s

              ON p.products_id = s.products_id

             WHERE

              p.products_status = 1

             ORDER BY

              p.products_date_added DESC,

              pd.products_name");


    while ($products = xtc_db_fetch_array($export_query)) {



      $products_price = xtc_get_products_price_export($products['products_id'],1,true,$_POST['status'],1,$_POST['currencies'],true);

     //Tausenderpunkt entfernen

     $products_price = str_replace(".","",$products_price);

  //dezimal Komma zu Punkt

  $products_price = str_replace(",",".",$products_price);

      // remove trash

      $products_description = strip_tags($products['products_description']);

      $products_description = substr($products_description, 0, 512 ) . '..';

       $products_description = str_replace(";",", ",$products_description);

      $products_description = str_replace("'",", ",$products_description);

      $products_description = str_replace("\n"," ",$products_description);

      $products_description = str_replace("\r"," ",$products_description);

      $products_description = str_replace("\t"," ",$products_description);

      $products_description = str_replace("\v"," ",$products_description);

      $products_description = str_replace("&quot,"," \"",$products_description);

      $products_description = str_replace("&qout,"," \"",$products_description);


      // get product categorie

      $categorie_query=xtc_db_query("SELECT

                      categories_id

                      FROM ".TABLE_PRODUCTS_TO_CATEGORIES."

                      WHERE products_id='".$products['products_id']."'");

       while ($categorie_data=xtc_db_fetch_array($categorie_query)) {

          $categories=$categorie_data['categories_id'];

       }

       $categorie_query=xtc_db_query("SELECT

                      categories_name

                      FROM ".TABLE_CATEGORIES_DESCRIPTION."

                      WHERE categories_id='".$categories."'

                      and language_id='".$_SESSION['languages_id']."'");

       $categorie_data=xtc_db_fetch_array($categorie_query);

  $categorie_data = str_replace(" ",">",$categorie_data);

      //create content


      //create content

if($products['products_image']==''){

$froogle_image="";

} else {

$froogle_image=HTTP_CATALOG_SERVER . DIR_WS_CATALOG_THUMBNAIL_IMAGES . $products['products_image'];

}

           $schema .=

            HTTP_CATALOG_SERVER . DIR_WS_CATALOG . 'product_info.php?products_id=' . $products['products_id']."\t".

            $products['products_name'] . "\t".

            $products_description ."\t".

    $froogle_image . "\t".

    $categorie_data['categories_name'] . "\t".

            $products_price. "\n";}



    // create File

     $fp = fopen(DIR_FS_DOCUMENT_ROOT.'export/' . $file, "w+");

     fputs($fp, $schema);

     fclose($fp);



   switch ($_POST['export']) {

    case 'yes':

      // send File to Browser

      $extension = substr($file, -3);

      $fp = fopen(DIR_FS_DOCUMENT_ROOT.'export/' . $file,"rb");

      $buffer = fread($fp, filesize(DIR_FS_DOCUMENT_ROOT.'export/' . $file));

      fclose($fp);

      header('Content-type: application/x-octet-stream');

      header('Content-disposition: attachment; filename=' . $file);

      echo $buffer;

      exit;


    break;

    }


  }


  function display() {


  $customers_statuses_array = xtc_get_customers_statuses();


  // build Currency Select

  $curr='';

  $currencies=xtc_db_query("SELECT code FROM ".TABLE_CURRENCIES);

  while ($currencies_data=xtc_db_fetch_array($currencies)) {

   $curr.=xtc_draw_radio_field('currencies', $currencies_data['code'],true).$currencies_data['code'].'<br>';

  }


  return array('text' => EXPORT_STATUS_TYPE.'<br>'.

             	EXPORT_STATUS.'<br>'.

             	xtc_draw_pull_down_menu('status',$customers_statuses_array, '1').'<br>'.

              CURRENCY.'<br>'.

              CURRENCY_DESC.'<br>'.

              $curr.

              EXPORT_TYPE.'<br>'.

              EXPORT.'<br>'.

             	xtc_draw_radio_field('export', 'no',false).EXPORT_NO.'<br>'.

              xtc_draw_radio_field('export', 'yes',true).EXPORT_YES.'<br>'.

              '<br>' . xtc_image_submit('button_export.gif', IMAGE_UPDATE) .


              '<a href="' . xtc_href_link(FILENAME_MODULE_EXPORT, 'set=' . $_GET['set'] . '&module=froogle') . '">' .

              xtc_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');



  }


  function check() {

   if (!isset($this->_check)) {

    $check_query = xtc_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_FROOGLE_STATUS'");

    $this->_check = xtc_db_num_rows($check_query);

   }

   return $this->_check;

  }


  function install() {

   xtc_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) values ('MODULE_FROOGLE_FILE', 'froogle.txt', '6', '1', '', now())");

   xtc_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) values ('MODULE_FROOGLE_STATUS', 'True', '6', '1', 'xtc_cfg_select_option(array(\'True\', \'False\'), ', now())");

}


  function remove() {

   xtc_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");

  }


  function keys() {

   return array('MODULE_FROOGLE_STATUS','MODULE_FROOGLE_FILE');

  }


 }

?>

Link to comment
Share on other sites

  • Replies 55
  • Created
  • Last Reply

Die description endet mit 2 Punkten

- dann ist keine Beschreibung des Artikels vorhanden

Es wird nur die unterste Kategorie ausgegeben. Hierin werden Blanks durch ">" ersetzt

- das > wird von froogle gefordert, nur die Unterste...? hmm pr?f ich noch mal

der Preis enth?lt keine Zeichen (1995 f?r 19.95)

- das ist bissel ein Problem, da jeder eine andere Formatierung verwendet. Kann aber ge?ndert werden, einfach mal die Zeile

//Tausenderpunkt entfernen

$products_price = str_replace(".","",$products_price);

//dezimal Komma zu Punkt

$products_price = str_replace(",",".",$products_price);

anpassen.

Erkl?rung:

Tausenderpunkt: wenn ein Punkt dann durch nichts ersetzt = (".","",

Dezikomma: Wenn ein Komma dann durch Punkt ersetzen = (",",".",

Halt das Ersetzen so anpassen das es dann so aussieht: 1243.57

Froggle will das Dezimal als Punkt und keine Tausendertrennung.

Gru? Haxley

Link to comment
Share on other sites

hallo,

wei? jemand was man angeben mu?, damit der Preis richtig gerundet wird von

--> 13.804 und mal so 1.2876 auf zwei stellen hinterm Komma???

Im Export Modul Froogle f?r 3.02 Version funktioniert das immer noch nicht richtig!!!!

Hab auch schon diberse Sachen ausprobiert:

CODE

$products_price. "\t" .

durch

CODE

number_format($products_price,2). "\t" .

ersetzen

funktioniert auch nicht!!!!!

Gru?

leinedesign

Link to comment
Share on other sites

Ich hatte meine froogle.txt mal zu froogle geladen... naja, "schwerwiegender Fehler" hi hi, man man man, warum m?ssen diese Bots das immer so schei... genau nehmen.

In der Description scheinen unter Umst?nden zu viele Leerzeichen zu erscheinen. Na mal sehn, ich mach mich mal dran, das es im Excel erst mal ordentlich aussieht, denn der Test bei Froogle kann sich paar Tage hinziehn.

Ich hatte des Froogle Modul auch mal zum DL bei XTC 3.0 gesehn. Find es aber nicht mehr.

Kann mir da mal jemand den Link geben oder es mir zusenden? Ich passe das dann an XTC 2.. an. Ist wohl besser sorum als das Rad noch mal neu zu erfinden.

Danke Gru? Haxley

Link to comment
Share on other sites

Hier ist es. Einfach mal f?r Euch testen:

<?php

/* -----------------------------------------------------------------------------------------

 $Id: froogle.php,v 0.2 2004/12/17 21:45:10 Haxley Exp $


 XT-Commerce - community made shopping

 http://www.xt-commerce.com


 Copyright (c) 2004 XT-Commerce

 -----------------------------------------------------------------------------------------

 based on:

 (c) 2000-2001 The Exchange Project (earlier name of osCommerce)

 (c) 2002-2003 osCommerce(cod.php,v 1.28 2003/02/14); [url]www.oscommerce.com[/url]

 (c) 2003 nextcommerce (invoice.php,v 1.6 2003/08/24); [url]www.nextcommerce.org[/url]


 Released under the GNU General Public License


 Modified for XT-Commerce by Haxley (froogle.php,v 0.2)

 http://www.plexcom.de, Dez , 2004

 Modified for XT-Commerce by SvFricke

 ---------------------------------------------------------------------------------------*/



define('MODULE_FROOGLE_TEXT_DESCRIPTION', 'Export - Froogle im txt Format');

define('MODULE_FROOGLE_TEXT_TITLE', 'Froogle - txt');

define('MODULE_FROOGLE_FILE_TITLE' , '<hr noshade>Dateiname');

define('MODULE_FROOGLE_FILE_DESC' , 'Geben Sie einen Dateinamen ein, falls die Exportadatei am Server gespeichert werden soll.<br>(Verzeichnis export/)');

define('MODULE_FROOGLE_STATUS_DESC','Modulstatus');

define('MODULE_FROOGLE_STATUS_TITLE','Status');

define('MODULE_FROOGLE_CURRENCY_TITLE','W?hrung');

define('MODULE_FROOGLE_CURRENCY_DESC','Welche W?hrung soll exportiert werden?');

define('EXPORT_YES','Nur Herunterladen');

define('EXPORT_NO','Am Server Speichern');

define('CURRENCY','<hr noshade><b>W?hrung:</b>');

define('CURRENCY_DESC','W?hrung in der Exportdatei');

define('EXPORT','Bitte den Sicherungsprozess AUF KEINEN FALL unterbrechen. Dieser kann einige Minuten in Anspruch nehmen.');

define('EXPORT_TYPE','<hr noshade><b>Speicherart:</b>');

define('EXPORT_STATUS_TYPE','<hr noshade><b>Kundengruppe:</b>');

define('EXPORT_STATUS','Bitte w?hlen Sie die Kundengruppe, die Basis f?r den Exportierten Preis bildet. (Falls Sie keine Kundengruppenpreise haben, w?hlen Sie <i>Gast</i>):</b>');

define('CHARSET','iso-8859-1');


// include needed functions


 class froogle {

  var $code, $title, $description, $enabled;



  function froogle() {

   global $order;


   $this->code = 'froogle';

   $this->title = MODULE_FROOGLE_TEXT_TITLE;

   $this->description = MODULE_FROOGLE_TEXT_DESCRIPTION;

   $this->sort_order = MODULE_FROOGLE_SORT_ORDER;

   $this->enabled = ((MODULE_FROOGLE_STATUS == 'True') ? true : false);


  }



  function process($file) {


    @xtc_set_time_limit(0);



    $schema .= 'product_url'."\t".'name'."\t".'description'."\t".'image_url'."\t".'category'."\t".'price'."\n";



    $export_query =xtc_db_query("SELECT

              p.products_id,

              pd.products_name,

              pd.products_description,

    p.products_image,

    p.products_discount_allowed,

    p.products_price,

              p.products_model,

              p.products_date_added,

              m.manufacturers_name

            FROM

              " . TABLE_PRODUCTS . " p 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 = '".$_SESSION['languages_id']."' LEFT JOIN

              " . TABLE_SPECIALS . " s

             ON p.products_id = s.products_id

            WHERE

             p.products_status = 1

            ORDER BY

              p.products_date_added DESC,

              pd.products_name");


    while ($products = xtc_db_fetch_array($export_query)) {



      $products_price = xtc_get_products_price_export($products['products_id'],1,true,$_POST['status'],1,$_POST['currencies'],true);

     //Tausenderpunkt entfernen

     //$products_price = str_replace(".","",$products_price);

   //dezimal Komma zu Punkt

   $products_price = str_replace(",","",$products_price);


   // get product categorie

      $categorie_query=xtc_db_query("SELECT

                      categories_id

                      FROM ".TABLE_PRODUCTS_TO_CATEGORIES."

                      WHERE products_id='".$products['products_id']."'");

       while ($categorie_data=xtc_db_fetch_array($categorie_query)) {

          $categories=$categorie_data['categories_id'];

       } 


      // remove trash

      $products_description = strip_tags($products['products_description']);

      //$products_description = substr($products_description, 0, 512 ) . '..';

      $products_description = str_replace(";",", ",$products_description);

      $products_description = str_replace("'",", ",$products_description);

      $products_description = str_replace("\n"," ",$products_description);

      $products_description = str_replace("\r"," ",$products_description);

      $products_description = str_replace("\t"," ",$products_description);

      $products_description = str_replace("\v"," ",$products_description);

      $products_description = str_replace("&quot,"," \"",$products_description);

      $products_description = str_replace("&qout,"," \"",$products_description);

      //$products_description = str_replace(chr(13),"",$products_description);

   $products_description = substr($products_description, 0, 65536);

     $cat = $this->buildCAT($categories);   





      //create content

if($products['products_image']==''){

$froogle_image="";

} else {

$froogle_image=HTTP_CATALOG_SERVER . DIR_WS_CATALOG_THUMBNAIL_IMAGES . $products['products_image'];

}

        $schema .=

         HTTP_CATALOG_SERVER . DIR_WS_CATALOG . 'product_info.php?products_id=' . $products['products_id']."\t".

         $products['products_name'] . "\t".

         $products_description ."\t".

     $froogle_image . "\t".

         substr($cat,0,strlen($cat)-2). "\t" .  

         $products_price. "\n";}

     //************************************************************************

    //** Ggfs. bei lokaler Verarbeitung: ?ndern lokale URL in Online-Shop URL

    //** Dadurch kann froogle Export auch lokal ausgef?hrt werden.

        // $schema = str_replace("XXX.domain.local","XXX.XXXonlinenameXXXX.de",$schema);            

    //************************************************************************


    // create File

     $fp = fopen(DIR_FS_DOCUMENT_ROOT.'export/' . $file, "w+");

     fputs($fp, $schema);

     fclose($fp);



   switch ($_POST['export']) {

    case 'yes':

      // send File to Browser

      $extension = substr($file, -3);

      $fp = fopen(DIR_FS_DOCUMENT_ROOT.'export/' . $file,"rb");

      $buffer = fread($fp, filesize(DIR_FS_DOCUMENT_ROOT.'export/' . $file));

      fclose($fp);

      header('Content-type: application/x-octet-stream');

      header('Content-disposition: attachment; filename=' . $file);

      echo $buffer;

      exit;


    break;

    }


  }


  function buildCAT($catID)

  {


    if (isset($this->CAT[$catID]))

    {

     return $this->CAT[$catID];

    } else {

      $cat=array();

      $tmpID=$catID;


        while ($this->getParent($catID)!=0 || $catID!=0)

        {

          $cat_select=xtc_db_query("SELECT categories_name FROM ".TABLE_CATEGORIES_DESCRIPTION." WHERE categories_id='".$catID."' and language_id='".$_SESSION['languages_id']."'");

          $cat_data=xtc_db_fetch_array($cat_select);

          $catID=$this->getParent($catID);

          $cat[]=$cat_data['categories_name'];


        }


;

        $catStr='';

        for ($i=count($cat);$i>0;$i--)

        {

         $catStr.=$cat[$i-1].' > ';

        }

        $this->CAT[$tmpID]=$catStr;

    return $this->CAT[$tmpID];

    }

  } 


  function getParent($catID)

  {

   if (isset($this->PARENT[$catID]))

   {

    return $this->PARENT[$catID];

   } else {

    $parent_query=xtc_db_query("SELECT parent_id FROM ".TABLE_CATEGORIES." WHERE categories_id='".$catID."'");

    $parent_data=xtc_db_fetch_array($parent_query);

    $this->PARENT[$catID]=$parent_data['parent_id'];

    return $parent_data['parent_id'];

   }

  } 


  function display() {


  $customers_statuses_array = xtc_get_customers_statuses();


  // build Currency Select

  $curr='';

  $currencies=xtc_db_query("SELECT code FROM ".TABLE_CURRENCIES);

  while ($currencies_data=xtc_db_fetch_array($currencies)) {

  $curr.=xtc_draw_radio_field('currencies', $currencies_data['code'],true).$currencies_data['code'].'<br>';

  }


  return array('text' => EXPORT_STATUS_TYPE.'<br>'.

             EXPORT_STATUS.'<br>'.

             xtc_draw_pull_down_menu('status',$customers_statuses_array, '1').'<br>'.

              CURRENCY.'<br>'.

              CURRENCY_DESC.'<br>'.

              $curr.

              EXPORT_TYPE.'<br>'.

              EXPORT.'<br>'.

             xtc_draw_radio_field('export', 'no',false).EXPORT_NO.'<br>'.

              xtc_draw_radio_field('export', 'yes',true).EXPORT_YES.'<br>'.

              '<br>' . xtc_image_submit('button_export.gif', IMAGE_UPDATE) .


              '<a href="' . xtc_href_link(FILENAME_MODULE_EXPORT, 'set=' . $_GET['set'] . '&module=froogle') . '">' .

              xtc_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');



  }


  function check() {

   if (!isset($this->_check)) {

    $check_query = xtc_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_FROOGLE_STATUS'");

    $this->_check = xtc_db_num_rows($check_query);

   }

   return $this->_check;

  }


  function install() {

   xtc_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) values ('MODULE_FROOGLE_FILE', 'froogle.txt', '6', '1', '', now())");

   xtc_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) values ('MODULE_FROOGLE_STATUS', 'True', '6', '1', 'xtc_cfg_select_option(array(\'True\', \'False\'), ', now())");

}


  function remove() {

   xtc_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");

  }


  function keys() {

   return array('MODULE_FROOGLE_STATUS','MODULE_FROOGLE_FILE');

  }


 }

?>

In Zeile 143 kann die Domain eingestellt werden, so dass der Export auch aus der lokalen DB erfolgen kann.

Gru?

Sven

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.


×
  • Create New...