Modul Einbauanleitung: Google Merchant Center inkl Taxonomie

Diskussionen die nicht direkt etwas mit einem Software oder Hardware Problem zu tun haben
Kopernikus
Beiträge: 390
Registriert: Fr 19. Okt 2012, 12:15

Modul Einbauanleitung: Google Merchant Center inkl Taxonomie

Beitrag von Kopernikus »

Grüsst Euch

Der Grund meines heutigen Beitrages ist mal nicht ein Problem, sondern das folgende Modul von Andreas Guder (http://www.andreas-guder.de/agi-softwar ... maerz.html) welches ich Euch hiermit vorstellen möchte. Die folgende Version (bis 1000 Artikel) habe ich von Herrn Guder komplett auf Webs umbauen lassen und seine Genehmigung erhalten, dieses hier öffentlich anbieten zu dürfen. Es gibt noch eine Primium Version, die noch zusätzliche Features enthält und für Shops über 1000 Artikel benötigt wird. Diese kann ebenfalls bei Herrn Guder (siehe Link oben) bezogen werden.

Nun aber alles von Beginn. Was genau macht oder kann dieses Modul?

Seit einiger Zeit bietet Google für Shopbesitzer eine neue Möglichkeit, Bilder und Preise direkt in die Suchabfragen zu integrieren. Ein Beispiel: Gebe ich die Suchbegriffe "la mer ultra" ein, erhalte ich folgende Anzeige von Google

Bild

Wie Ihr im Bild oben seht, werden nun gleich vier meiner Produkte aus dem Shop sehr übersichtlich präsentiert. Bei einem Klick auf ein jeweiliges Produkt, landet der Kunde also direkt auf der Produkteseite des jeweiligen Artikels.

Das ist nun die bildliche Beschreibung dieses Moduls. Doch was macht dieses genau?

Dieses Modul überträgt Produkte in einem XML-Datenfeed in das Google-Merchant-Center. Einmal eingerichtet, kann die URL des Datenfeeds im Google-Merchant-Center hinterlegt werden, worauf Google diesen regelmässig abrufen wird. D.h. Ihr müsst Euch um nichts mehr kümmern. Egal ob Ihr neue Produkte, Aktionen, andere Staffelpreise, ein anderes Bild etc. erfasst, der Feed wird automatisch innert vorgegebener Zeit (in der Regel innert 24h) automatisch angepasst. Der manuelle Upload entfällt also vollständig.

Die wichtigsten Features

Vorbereitet für die Produkt-Feed-Spezifikation gültig ab Juli 2013
Das Modul ist angepasst an die Google-Produkt-Feed-Spezifikation gültig am Juli 2013.
Neue Eigenschaften wie „Kennzeichnung existiert“, „Nicht jugendfrei“, „Energieeffizienzklasse“ und die Grundpreis-Eigenschaften wurden ergänzt.

Google-Kategorien, Google-Taxonomie
In einem separaten Menüpunkt könnt Ihr alle benötigten Google-Kategorien speichern. Aus dieser Auswahl an Kategorien wird eine dynamische Liste erzeugt, welche im Admin-Bereich am Produkt und den Shop-Kategorien angezeigt wird. Durch anklicken eines Listenpunktes wird dem Produkt bzw. der Shop-Kategorie eine Google-Kategorie zuordnet. Das Modul arbeitet rekursiv. Beim erstellen des Datenfeeds wird geprüft, ob dem Produkt eine Google-Kategorie zugeordnet ist. Ist dies nicht der Fall, wird die Shop-Kategorie des Produktes auf eine Google-Kategorie geprüft. Ist dieser auch keine Google-Kategorie zugeordnet, wird in der nächst höheren Shop-Kategorie danach geschaut. Ist die oberste Ebene erreicht und noch immer keine Google-Kategorie gefunden, wird eine zuvor festgelegte Standard-Kategorie exportiert. Die verfügbaren Google-Kategorien findet Ihr hier: http://www.google.com/basepages/product ... .de-DE.txt

Bild

Verfügbarkeit
Produkte können als „immer Verfügbar“ exportiert werden, oder Anhand der verfügbaren Anzahl als verfügbar oder nicht verfügbar.

Pagination, große Datenfeeds
Sollte Dein Server nicht in der Lage sein, Aufgrund der Anzahl an Produkten, den kompletten Feed zu erstellen, lässt sich dieser automatisch in mehrere Feeds aufteilen.
Dafür steht der Parameter „page=x“ zur Verfügung. Je Seite/Feed werden per default 5000 Produkte ausgegeben. Die Anzahl an Produkte je Seite kann individuell im Script angepasst werden.

Caching, Zwischenspeicher
Um die Serverlast zu reduzieren und den Feed nicht bei jedem Aufruf neu erstellen zu lassen, wird dieser für mindestens 24 Stunden zwischengespeichert. In der Premium-Version erfolgt gzip-komprimiert. Die Caching-Funktion kann auch genutzt werden, um den Feed noch vor den Google-Aufrufen per Cronjob erstellen zu lassen, sodass Google beim Aufruf der URL bereits die zwischengespeicherte Version erhält, was die Übertragungszeit verringert.

Das Modul funktioniert auch in der Schweiz.

Weitere Informationen oder die Premium Version erhält Ihr auch direkt auf der Seite von Herrn Guder http://www.andreas-guder.de/agi-softwar ... maerz.html


OK, dann geht's nun an den Einbau ;)

Hinweise:
=======================
Legt vor dem Einbau, von allen zu ändernden Dateien eine Sicherungskopie an!
Das Verzeichnis /export/ muss beschreibbar sein und darf nicht etwa durch die .htaccess Datei gesperrt werden.

Die Datei /admin/google_taxonomie.php erfordert PHP Version 5
Solltet Ihr noch eine tiefere Version laufen haben, geht bitte auf die Seite von Herrn Guder und zieht Euch ein aktuelles Installations-Paket. Dort findet Ihr auch eine Version für PHP 4. Die Datei /admin/google_taxonomie.php.fuer-php-4.php muss dann allerdings entsprechend angepasst werden, da die Änderungen für Webs in der Datei google_taxonomie.php gemacht wurden.

Ok, dann mal los

Erstellt die folgenden, neuen Dateien und legt diese in den angegebenen Verzeichnissen Eures Shops ab:

/admin/google_taxonomie.php

Code: Alles auswählen

<?php
/* admin/google_taxonomie.php
.---------------------------------------------------------------------------.
|    Software: GOOGLE-Shopping XML-Export for modified-shops and xt:c 3     |
|      Author: Andreas Guder                                                |
|     Version: 1                                                            |
|     Contact: info@andreas-guder.de / http://www.andreas-guder.de          |
| Copyright (c) 2013, Andreas Guder [info@andreas-guder.de]                 |
|               GNU General Public License                                  |
'--------------------------------------------------------------------------�'
*/
  require('includes/application_top.php');
  class GOOGLE_TAXONOMIE
  {
    private $taxonomie_array  = array();
    private $taxonomie_file   = array();
    
    /**
     * @param   string path to google-taxonomieflile
     */
    public function __construct($file)
    {
      if (file_exists($file))
      {
        $this->taxonomie_file = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
      }
      $this->file_to_array();
    }
    
    /**
     * create $taxonomie_array from $taxonomie_file
     */
    private function file_to_array()
    {
      foreach ($this->taxonomie_file as $row)
      {
        $is_empty = preg_replace('/\s/', '', $row);
        if (empty($is_empty))
          continue;
        $google_cats = explode('>',$row);
        $ref = &$this->taxonomie_array;
        foreach ($google_cats as $category)
        {
          $check_cat = trim($category);
          if (array_key_exists($check_cat, $ref))
          {
            $ref = &$ref[$check_cat];
          }
          else
          {
            $ref[$check_cat] = array();
            $ref = &$ref[$check_cat];
          }
        }
      }
    }
    
    /**
     * create json-string of given array
     * @param   array $array: array to create json from
     * @param   array $child_path: child-elements of the given array
     * @return  string
     */
    private function array_to_json($array, $child_path = array())
    {
      $string = '';
      $count = 0;
      foreach($array as $key => $value)
      {
        $add_child_path = $child_path;
        $add_child_path[] = $key;
        if($count > 0)
          $string .= ',';
        $string .= '"'.rawurlencode($key).'":{';
        $string .= '"string":"'.rawurlencode(implode(' > ', $add_child_path)).'"';
        if (!empty($value))
        {
          $string .= ',"childs":{';
          $string .= $this->array_to_json($value, $add_child_path);
          $string .= '}';
        }
        $string .= '}';
        $count++;
      }
      return $string;
    }
    
    /**
     * public function to handle json-string (save to file or return as string
     * @param   string  $save_path: path (and name) of file to create, or empty to return string only
     * @param   string  $wrap:  string to wrap the json-string use "%s" for explode
     * @return  mixed   string/bool
     */
    public function taxonomie_to_json($save_path = '', $wrap = 'var g_taxonimie = eval(%s)')
    {
      $string = '';
        $wrap_explode = !empty($wrap) ? explode('%s',$wrap) : array('','');
      if ($wrap_explode[0])
        $string .= $wrap_explode[0];
      $string .= '{';
      $string .= '"string":""';
      $string .= ',"childs":{';
      $string .= $this->array_to_json($this->taxonomie_array);
      $string .= '}}';
      if ($wrap_explode[1])
        $string .= $wrap_explode[1];
      if (empty($save_path))
        return $string;
      else
      {
        // try to write file
        if ($fp = fopen($save_path, 'w'))
        {
          fwrite($fp, $string);
          fclose($fp);
          return true;
        }
        else
          return false;
      }
    }
  }
  define('FILENAME_AGI_GOOGLE_TAXONOMIE','google_taxonomie.php');
  
$print_error = array();
switch ($_GET['action']) {
  case 'save':
    if ($fp = fopen(DIR_FS_DOCUMENT_ROOT.'export/google_taxonomie.txt', 'w'))
    {
      fwrite($fp, $_POST['google_cats']);
      fclose($fp);
      if (file_exists(DIR_FS_DOCUMENT_ROOT.'export/google_taxonomie.txt'))
      {
        $google = new GOOGLE_TAXONOMIE(DIR_FS_DOCUMENT_ROOT.'export/google_taxonomie.txt');
        $success = $google->taxonomie_to_json(DIR_FS_DOCUMENT_ROOT.'export/google_taxonomie.json.js');
        if (!$success)
          $print_error[] = 'google_taxonomie.json.js konnte nicht erstellt werden';
      }
      xtc_redirect(FILENAME_AGI_GOOGLE_TAXONOMIE);
    }
    else
      $print_error[] = 'google_taxonomie.txt konnte nicht erstellt werden';
  break;
}

// get file_information
$google_text = 'not available';
$google_json = 'not available';
$google_file = '';
if (file_exists(DIR_FS_DOCUMENT_ROOT.'export/google_taxonomie.txt'))
{
  $info = filemtime(DIR_FS_DOCUMENT_ROOT.'export/google_taxonomie.txt');
  $google_text = 'Date: '.date('Y-m-d H:i',$info);
  if (!is_writable(DIR_FS_DOCUMENT_ROOT.'export/google_taxonomie.txt'))
    $google_text .= ' NOT writable, please ask your administrator';
  $google_file = file_get_contents(DIR_FS_DOCUMENT_ROOT.'export/google_taxonomie.txt');
}
if (file_exists(DIR_FS_DOCUMENT_ROOT.'export/google_taxonomie.json.js'))
{
  $info = filemtime(DIR_FS_DOCUMENT_ROOT.'export/google_taxonomie.json.js');
  $google_json = 'Date: '.date('Y-m-d H:i',$info);
  if (!is_writable(DIR_FS_DOCUMENT_ROOT.'export/google_taxonomie.json.js'))
    $google_json .= ' NOT writable, please ask your administrator';
}

?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $_SESSION['language_charset']; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script type="text/javascript" src="includes/general.js"></script>

</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
  <tr>
    <td class="columnLeft2" width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- left_navigation_eof //-->
    </table></td>
<!-- body_text //-->
    <td class="boxCenter" width="100%" valign="top">
      <table border="0" width="100%" cellspacing="0" cellpadding="0">
        <tr>
          <td>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td width="80" rowspan="2"><?php echo xtc_image(DIR_WS_ICONS.'heading_news.gif'); ?></td>
    <td class="pageHeading">Google Taxonomie</td>
  </tr>
  <tr>
    <td class="main" valign="top"><a href="http://www.andreas-guder.de" onClick="window.open(this.href,'_blank',''); return false;">AGI - Internetagentur Andreas Guder</a></td>
  </tr>
</table>
        </td>
      </tr>
      <tr>
        <td class="main">
<table class="infoBoxHeading" width="100%">
  <tr>
    <td width="250">export/google_taxonomie.txt</td>
    <td><?php echo $google_text; ?></td>
  </tr>
  <tr>
    <td width="250">export/google_taxonomie.json.js</td>
    <td><?php echo $google_json; ?></td>
  </tr>
  <tr>
    <td width="250">Google taxonomy.de-DE.txt</td>
    <td><a href="http://www.google.com/basepages/producttype/taxonomy.de-DE.txt" onClick="window.open(this.href,'_blank',''); return false;">http://www.google.com/basepages/producttype/taxonomy.de-DE.txt</a></td>
  </tr>
</table>
<table width="100%"  border="0" cellspacing="5" cellpadding="0">
  <tr>
    <td class="pageHeading">Google-Taxonomie-Datei:</td>
  </tr>
  <tr>
    <td class="dataTableHeadingContent">
<?php
  echo xtc_draw_form('google_taxonomie',FILENAME_AGI_GOOGLE_TAXONOMIE,'action=save','POST');
  echo xtc_draw_textarea_field('google_cats','', 60, 30, $google_file, 'style="width: 90%"');
  echo '<br/><input type="submit" class="button" onClick="this.blur();" value="' . BUTTON_SAVE . '"/>';
?>
  </form>
  <p>&nbsp; </p>
    </td>
  </tr>
</table>


        </td>
      </tr>
    </table>
  </td>
<!-- body_text_eof //-->
  </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
/admin/includes/modules/agi_google_export.php

Code: Alles auswählen

<?php
  $agi_google_destination_options = array(
    array('id' => '', 'text' => TEXT_NONE),
    array('id' => 'Shopping', 'text' => 'Shopping'),
    array('id' => 'Commerce Search', 'text' => 'Commerce Search')
  );
  $agi_google_condition_options = array(
    array('id' => 'new', 'text' => TEXT_GOOGLE_CONDITION_NEW),
    array('id' => 'used', 'text' => TEXT_GOOGLE_CONDITION_USED),
    array('id' => 'refurbished', 'text' => TEXT_GOOGLE_CONDITION_REFURBISHED)
  );
  $agi_google_energy_options = array(
    array('id' => '', 'text' => ''),
    array('id' => 'A+++', 'text' => 'A+++'),
    array('id' => 'A++', 'text' => 'A++'),
    array('id' => 'A+', 'text' => 'A+'),
    array('id' => 'A', 'text' => 'A'),
    array('id' => 'B', 'text' => 'B'),
    array('id' => 'C', 'text' => 'C'),
    array('id' => 'D', 'text' => 'D'),
    array('id' => 'E', 'text' => 'E'),
    array('id' => 'F', 'text' => 'F'),
    array('id' => 'G', 'text' => 'G')
  );
?>
<table style="width: 100%;" cellspacing="0" cellpadding="3">
  <tr>
    <td><span class="main"><?php echo AGI_GOOGLE_EXPORT_ALLOWED ?></span></td>
    <td><?php echo xtc_draw_selection_field('agi_google_export', 'checkbox', '1', $pInfo->agi_google_export==1 ? true : false); ?></td>
    <td style="width: 30px"></td>
    <td><span class="main"><?php echo AGI_GOOGLE_ONLINE_ONLY ?></span></td>
    <td><?php echo xtc_draw_selection_field('agi_google_online_only', 'checkbox', '1', $pInfo->agi_google_online_only==1 ? true : false); ?></td>
  </tr>
  <tr>
    <td><span class="main"><?php echo AGI_GOOGLE_CONDITION ?></span></td>
    <td><?php echo xtc_draw_pull_down_menu('agi_google_condition', $agi_google_condition_options, $pInfo->agi_google_condition); ?></td>
    <td style="width: 30px"></td>
    <td><span class="main"><?php echo AGI_GOOGLE_IDENTIFIER_EXISTS ?></span></td>
    <td><?php echo xtc_draw_selection_field('agi_google_identifier_exists', 'checkbox', '1', $pInfo->agi_google_identifier_exists==1 ? true : false); ?></td>
  </tr>
  <tr>
    <td><span class="main"><?php echo AGI_GOOGLE_PRODUCTS_BRAND ?></span></td>
    <td><?php echo xtc_draw_input_field('agi_google_products_brand', $pInfo->agi_google_products_brand, 'style="width:100%"'); ?></td>
    <td style="width: 30px"></td>
    <td><span class="main"><?php echo AGI_GOOGLE_ENERGY_EFFICIENCY ?></span></td>
    <td><?php echo xtc_draw_pull_down_menu('agi_google_energy_efficiency', $agi_google_energy_options, $pInfo->agi_google_energy_efficiency); ?></td>
  </tr>
  <tr>
    <td><span class="main"><?php echo AGI_GOOGLE_MULTIPACK_AMOUNT ?></span></td>
    <td><?php echo xtc_draw_input_field('agi_google_multipack_amount', $pInfo->agi_google_multipack_amount, 'style="width:100%"'); ?></td>
    <td style="width: 30px"></td>
    <td></td>
    <td></td>
  </tr>
  <tr>
    <td><span class="main"><?php echo AGI_GOOGLE_ADWORDS_GROUPING ?></span></td>
    <td><?php echo xtc_draw_input_field('agi_google_adwords_grouping', $pInfo->agi_google_adwords_grouping, 'style="width:100%"'); ?></td>
    <td style="width: 30px"></td>
    <td><span class="main"><?php echo AGI_GOOGLE_ADWORDS_LABELS ?></span></td>
    <td><?php echo xtc_draw_input_field('agi_google_adwords_labels', $pInfo->agi_google_adwords_labels, 'style="width:100%"'); ?></td>
  </tr>
  <tr>
    <td><span class="main"><?php echo AGI_GOOGLE_ADWORDS_REDIRECT ?></span></td>
    <td colspan="4"><span class="main"><?php echo xtc_draw_input_field('agi_google_adwords_redirect', $pInfo->agi_google_adwords_redirect, 'style="width:100%"'); ?></span></td>
  </tr>
  <tr>
    <td><span class="main"><?php echo AGI_GOOGLE_EXCLUDED_DESTINATION ?></span></td>
    <td><?php echo xtc_draw_pull_down_menu('agi_google_excluded_destination', $agi_google_destination_options, $pInfo->agi_google_excluded_destination); ?></td>
    <td style="width: 30px"></td>
    <td><span class="main"><?php echo AGI_GOOGLE_EXPIRATION_DATE ?></span></td>
    <td><?php echo xtc_draw_input_field('agi_google_expiration_date', $pInfo->agi_google_expiration_date, 'style="width: 135px"'); ?></td>
  </tr>
  <tr>
    <td><span class="main"><?php echo AGI_GOOGLE_CATEGORY; ?></span>
    <td colspan="4"><?php echo xtc_draw_input_field('google_category', $pInfo->google_category, 'size="50" style="width: 100%"'); ?></td>
  </tr>
  <tr>
    <td colspan="5"><div id="g_taxonomie_select"></div></td>
  </tr>
</table>
<script type="text/javascript" src="../export/google_taxonomie.json.js"></script>
<script type="text/javascript">
  if (g_taxonimie && document.getElementById('g_taxonomie_select') && document.getElementsByName('google_category'))
    create_agi_google_taxonomie();
  function create_agi_google_taxonomie()
  {
    var parent = document.getElementById('g_taxonomie_select');
    var ul = document.createElement('UL');
    ul.className = 'agi_taxonomie_select';
    parent.appendChild(ul);
    build_taxonomie_list_element(ul, '---', '');
    if (g_taxonimie.childs)
      build_agi_taxonomie_list(ul, g_taxonimie.childs);
  }
  function build_agi_taxonomie_list(parent, taxonomie_object)
  {
    for (var i in taxonomie_object)
    {
      var li = build_taxonomie_list_element(parent, i, taxonomie_object[i].string);
      li.className = 'agi_taxonomie_li'; // just for IE in Quirksmode
      if (taxonomie_object[i].childs)
      {
        var ul = document.createElement('UL');
        ul.className = 'agi_taxonomie_ul'; // just for IE in Quirksmode
        li.appendChild(ul);
        li.className = 'has_childs';
        li.onmouseover   = new Function('hover_taxonomie_list_element(this)');
        build_agi_taxonomie_list(ul, taxonomie_object[i].childs);
      }
    }
  }
  function build_taxonomie_list_element(parent, text, value)
  {
    var li = document.createElement('LI');
    parent.appendChild(li);
    var span = document.createElement('SPAN');
    span.className = 'agi_taxonomie_span'; // just for IE in Quirksmode
    li.appendChild(span);
    span.appendChild(document.createTextNode(decodeURIComponent(text)));
    span.onclick = new Function ("document.getElementsByName('google_category')[0].value='"+decodeURIComponent(value)+"'");
    return li;
  }
  function hover_taxonomie_list_element(me)
  {
    var myParent = me.parentNode;
    var lis = myParent.getElementsByTagName('LI');
    for (var i=0; i<lis.length; i++)
    {
      lis[i].className = lis[i].className.replace(new RegExp(" hover\\b"), "");
      lis[i].onmouseover = new Function('hover_taxonomie_list_element(this)');
    }
    me.className+=" hover";
    me.onmouseover = '';
  }
</script>
<!-- AGI google-taxonomie http://www.andreas-guder.de  END -->
/admin/includes/modules/export/agi_google_xml.php

Code: Alles auswählen

<?php
/* admin/includes/modules/export/agi_google_xml.php
.---------------------------------------------------------------------------.
|    Software: GOOGLE-Shopping XML-Export for modified-shops and xt:c 3     |
|      Author: Andreas Guder                                                |
|     Version: 1.4 Standard                                                 |
|     Contact: info@andreas-guder.de / http://www.andreas-guder.de          |
| Copyright (c) 2013, Andreas Guder [info@andreas-guder.de]                 |
|               GNU General Public License                                  |
'--------------------------------------------------------------------------�'
*/
defined( '_VALID_XTC' ) or die( 'Direct Access to this location is not allowed.' );

define('MODULE_AGI_GOOGLE_XML_DESCRIPTION', 'XML-Datenfeed f&uuml;r Google-Merchant-Center,<br />aktiviert die Datei /export/google_xml.php');
define('MODULE_AGI_GOOGLE_XML_TEXT_TITLE', 'XML-Datenfeed f&uuml;r Google-Merchant-Center');

define('MODULE_AGI_GOOGLE_XML_STATUS_TITLE', 'Modul aktiv');
define('MODULE_AGI_GOOGLE_XML_STATUS_DESC', 'Soll das Modul aktiviert werden?');
define('MODULE_AGI_GOOGLE_XML_VPE_TITLE_TITLE', 'Grundpreis im Titel');
define('MODULE_AGI_GOOGLE_XML_VPE_TITLE_DESC', 'Die Grundpreisauszeichnung wird an den Produkttitel angef&uuml;gt');
define('MODULE_AGI_GOOGLE_XML_VPE_DESCRIPTION_TITLE', 'Grundpreis in der Beschreibung');
define('MODULE_AGI_GOOGLE_XML_VPE_DESCRIPTION_DESC', 'Die Grundpreisauszeichnung wird der Beschreibung vorangestellt');
define('MODULE_AGI_GOOGLE_XML_LONG_DESCRIPTION_TITLE', 'Artikelbeschreibung exportieren');
define('MODULE_AGI_GOOGLE_XML_LONG_DESCRIPTION_DESC', 'Artikelbeschreibung anstelle der Kurzbeschreibung exportieren?');
define('MODULE_AGI_GOOGLE_XML_AVAILABILITY_FROM_QUANTITY_TITLE', 'Bestandsabh&auml;ngige Verf&uuml;gbarkeit');
define('MODULE_AGI_GOOGLE_XML_AVAILABILITY_FROM_QUANTITY_DESC', 'Bestandsabh&auml;ngige Verf&uuml;gbarkeit &uuml;bermitteln anstelle von dauerhaft "in stock"');
define('MODULE_AGI_GOOGLE_XML_SHIPPING_LIST_TITLE', 'Versandkosten');
define('MODULE_AGI_GOOGLE_XML_SHIPPING_LIST_DESC', 'Die Versandkosten basieren auf dem Artikelpreis oder dem Artikelgewicht. Beispiel: 25:4.90,50:9.90,etc.. Bis 25 werden 4.90 verrechnet, dar&uuml;ber bis 50 werden 9.90 verrechnet, etc.');
define('MODULE_AGI_GOOGLE_XML_SHIPPING_BASE_TITLE', 'Versandkosten-Basis');
define('MODULE_AGI_GOOGLE_XML_SHIPPING_BASE_DESC', 'Die Versandkosten basieren auf dem Artikelpreis oder dem Artikelgewicht.');
define('MODULE_AGI_GOOGLE_CHECK_GRADUATED_PRICE_TITLE', 'Staffelpreise beachten');
define('MODULE_AGI_GOOGLE_CHECK_GRADUATED_PRICE_DESC', 'der g�nstigste Staffelpreis wird zu Google �bertragen');
define('MODULE_AGI_GOOGLE_IGNORE_FREESHIPPING_MODULES_TITLE', 'Versandkostenfrei-Einstellungen ignorieren');
define('MODULE_AGI_GOOGLE_IGNORE_FREESHIPPING_MODULES_DESC', 'Einstellungen aus den Modulen ot_shipping und freeamount, durch die Versand ab einem bestimmten Preis kostenfrei wird, werden ignoriert.');

define('MODULE_AGI_GOOGLE_XML_GENDER_WORDS_MALE_TITLE', 'Attributwerte f&uuml;r "Herren"');
define('MODULE_AGI_GOOGLE_XML_GENDER_WORDS_MALE_DESC', 'Geben Sie Ihre verwendeten Attributwerte an, die f&uuml;r "m&auml;nnlich" stehen. (klein, mit Komma hintereinander)');
define('MODULE_AGI_GOOGLE_XML_GENDER_WORDS_FEMALE_TITLE', 'Attributwerte f&uuml;r "Damen"');
define('MODULE_AGI_GOOGLE_XML_GENDER_WORDS_FEMALE_DESC', 'Geben Sie Ihre verwendeten Attributwerte an, die f&uuml;r "weiblich" stehen. (klein, mit Komma hintereinander)');
define('MODULE_AGI_GOOGLE_XML_GENDER_WORDS_UNISEX_TITLE', 'Attributwerte f&uuml;r "Unisex"');
define('MODULE_AGI_GOOGLE_XML_GENDER_WORDS_UNISEX_DESC', 'Geben Sie Ihre verwendeten Attributwerte an, die f&uuml;r "geschlechtsneutral" stehen. (klein, mit Komma hintereinander)');
define('MODULE_AGI_GOOGLE_XML_AGE_GROUP_WORDS_KIDS_TITLE', 'Attributwerte f&uuml;r "Kinder"');
define('MODULE_AGI_GOOGLE_XML_AGE_GROUP_WORDS_KIDS_DESC', 'Geben Sie Ihre verwendeten Attributwerte an, die f&uuml;r "Kinder" stehen. (klein, mit Komma hintereinander)');
define('MODULE_AGI_GOOGLE_XML_AGE_GROUP_WORDS_ADULT_TITLE', 'Attributwerte f&uuml;r "Erwachsen"');
define('MODULE_AGI_GOOGLE_XML_AGE_GROUP_WORDS_ADULT_DESC', 'Geben Sie Ihre verwendeten Attributwerte an, die f&uuml;r "Erwachsene" stehen. (klein, mit Komma hintereinander)');
define('MODULE_AGI_GOOGLE_XML_DEFAULT_CATEGORY_TITLE', 'Standard Google-Kategorie');
define('MODULE_AGI_GOOGLE_XML_DEFAULT_CATEGORY_DESC', 'Diese Google-Kategorie wird ausgegeben, wenn dem Produkt keine Google-Kategorie zugeordnet werden kann.');
define('MODULE_AGI_GOOGLE_XML_CAMPAIGN_TITLE', 'Kampanien-Parameter');
define('MODULE_AGI_GOOGLE_XML_CAMPAIGN_DESC', 'Diese Parameter werden jedem Produktlink angef&uuml;gt. Bspl: pk_campaign=google_shopping');

define('MODULE_AGI_GOOGLE_XML_USE_PRODUCT_IMAGE_TITLE', 'Bilder verwenden');
define('MODULE_AGI_GOOGLE_XML_USE_PRODUCT_IMAGE_DESC', 'Diese Produktbilder werden exportiert.');

class agi_google_xml {

  function agi_google_xml()
  {
    if (defined('MODULE_AGI_GOOGLE_XML_STATUS'))
      $this->enabled = (MODULE_AGI_GOOGLE_XML_STATUS == 'TRUE') ? true : false;
    else
      $this->enabled = false;
    $this->code         = 'agi_google_xml';
    $this->title        = MODULE_AGI_GOOGLE_XML_TEXT_TITLE;
    $this->description  = MODULE_AGI_GOOGLE_XML_DESCRIPTION;
    $this->sort_order   = MODULE_AGI_GOOGLE_XML_SORT_ORDER;
  }
  
  function process() 
  {
    // do nothing
  }
  
  function display() 
  {
    $this->do_modul_updates();
    // print more instructions
    $text = '<hr /><br />Nachdem Sie das Modul aktiviert haben, geben Sie im Google MerchantCenter die URL zur Exportdatei an:';
    $text .= '<br /><em>"'.HTTP_SERVER.'/export/google_xml.php"</em>';
    $text .= '<br />Der Aufruf der URL erzeugt automatisch die aktuellste Produktliste Ihres Shops, sofern er au&szlig;erhalb des Cache-Zeitraums erfolgt.';
    $text .= '<br />Der Standard-Cache-Zeitraum ist auf 1 Tag eingestellt, dadurch wird die Produktliste nur einmal t&auml;glich neu erstellt.';
    $text .= '<br />Mit dem Parameter "cache=" an der URL k&ouml;nnen Sie Anzahl der Tage bei Bedarf beeinflussen.';
    
    $text .= '<br /><br />Ab einer gesch&auml;tzten Anzahl von 3000 Shop-Artikeln ist es unter Umst&auml;nden nicht mehr m&ouml;glich, die komplette XML-Datei zu erstellen.';
    $text .= '<br /><em>(Stichworte: Server-Timeout, Memory-Limit)</em>';
    $text .= '<br />In diesen F&auml;llen m&uuml;ssen Sie die Produktliste in mehrere Seiten aufteilen:';
    $text .= '<br />Legen Sie im Merchant-Center mehrere Feeds mit der genannten URL an.';
    $text .= '<br />Erg&auml;nzen Sie an jeder URL den Parameter "page=X".';
    $text .= '<br />Anstelle von "X" geben Sie eine Seitenzahl 1 bis X an';
    $text .= '<br />Seitenzahl 1 gibt die ersten 3000 Produkte aus, Seitenzahl 2 die Produkte 3000 bis 6000, Seitenzahl 3 die Produkte 6000 bis 9000, usw.';
    $text .= '<br />Bei Bedarf kann die Anzahl der Produkte pro Seite in der Datei "export/google_xml.php" ge&auml;ndert werden.';
    
    $text .= '<br /><br />Au&szlig;erdem stehen folgende URL-Parameter zur Verf&uuml;gung:';
    $text .= '<br />"lang=" ID der Sprache, die verwendet werden soll. (Standard: 2 = deutsch)';
    $text .= '<br />"group=" ID der Kundengruppe, die verwendet werden soll. (Standard: 1 = Gast)';
    $text .= '<br /><br />';
    $text .= '<br />Autor: <a href="http://www.andreas-guder.de" target="_blank">www.andreas-guder.de</a><br />';

    $text .= '<br />' . xtc_button(BUTTON_SAVE);
    $text .= xtc_button_link(BUTTON_CANCEL, xtc_href_link(FILENAME_MODULE_EXPORT, 'set=' . $_GET['set'] . '&module=agi_google_xml'));
    return array('text'=>$text);
  }
  
  function check() 
  {
    if (!isset($this->_check)) 
    {
      $check_query = xtc_db_query("SELECT `configuration_value` FROM " . TABLE_CONFIGURATION . " WHERE `configuration_key` = 'MODULE_AGI_GOOGLE_XML_STATUS'");
      $this->_check = xtc_db_num_rows($check_query);
    }
    return $this->_check;
  }

  function install() 
  {
    if (!defined('MODULE_AGI_GOOGLE_XML_STATUS'))
    {
      xtc_db_query("INSERT INTO `" . TABLE_CONFIGURATION . "` (`configuration_key`, `configuration_value`, `configuration_group_id`, `sort_order`, `set_function`, `date_added`) VALUES ('MODULE_AGI_GOOGLE_XML_STATUS', 'TRUE', '6', '1', 'xtc_cfg_select_option(array(\'TRUE\', \'FALSE\'), ', now())");
      xtc_db_query("INSERT INTO `" . TABLE_CONFIGURATION . "` (`configuration_key`, `configuration_value`, `configuration_group_id`, `sort_order`, `set_function`, `date_added`) VALUES ('MODULE_AGI_GOOGLE_XML_VPE_TITLE', 'FALSE', '6', '1', 'xtc_cfg_select_option(array(\'TRUE\', \'FALSE\'), ', now())");
      xtc_db_query("INSERT INTO `" . TABLE_CONFIGURATION . "` (`configuration_key`, `configuration_value`, `configuration_group_id`, `sort_order`, `set_function`, `date_added`) VALUES ('MODULE_AGI_GOOGLE_XML_VPE_DESCRIPTION', 'FALSE', '6', '1', 'xtc_cfg_select_option(array(\'TRUE\', \'FALSE\'), ', now())");
      xtc_db_query("INSERT INTO `" . TABLE_CONFIGURATION . "` (`configuration_key`, `configuration_value`, `configuration_group_id`, `sort_order`, `set_function`, `date_added`) VALUES ('MODULE_AGI_GOOGLE_XML_LONG_DESCRIPTION', 'TRUE', '6', '1', 'xtc_cfg_select_option(array(\'TRUE\', \'FALSE\'), ', now())");
      xtc_db_query("INSERT INTO `" . TABLE_CONFIGURATION . "` (`configuration_key`, `configuration_value`, `configuration_group_id`, `sort_order`, `set_function`, `date_added`) VALUES ('MODULE_AGI_GOOGLE_XML_AVAILABILITY_FROM_QUANTITY', 'TRUE', '6', '1', 'xtc_cfg_select_option(array(\'TRUE\', \'FALSE\'), ', now())");
      xtc_db_query("INSERT INTO `" . TABLE_CONFIGURATION . "` (`configuration_key`, `configuration_value`, `configuration_group_id`, `sort_order`, `set_function`, `date_added`) VALUES ('MODULE_AGI_GOOGLE_CHECK_GRADUATED_PRICE', 'FALSE', '6', '1', 'xtc_cfg_select_option(array(\'TRUE\', \'FALSE\'), ', now())");
      xtc_db_query("INSERT INTO `" . TABLE_CONFIGURATION . "` (`configuration_key`, `configuration_value`, `configuration_group_id`, `sort_order`, `set_function`, `date_added`) VALUES ('MODULE_AGI_GOOGLE_IGNORE_FREESHIPPING_MODULES', 'FALSE', '6', '1', 'xtc_cfg_select_option(array(\'TRUE\', \'FALSE\'), ', now())");
      xtc_db_query("INSERT INTO `" . TABLE_CONFIGURATION . "` (`configuration_key`, `configuration_value`, `configuration_group_id`, `sort_order`, `set_function`, `date_added`) VALUES ('MODULE_AGI_GOOGLE_XML_SHIPPING_BASE', 'price', '6', '1', 'xtc_cfg_select_option(array(\'price\', \'weight\'), ', now())");
      xtc_db_query("INSERT INTO `" . TABLE_CONFIGURATION . "` (`configuration_key`, `configuration_value`, `configuration_group_id`, `sort_order`, `set_function`, `date_added`) VALUES ('MODULE_AGI_GOOGLE_XML_SHIPPING_LIST', '0:4.95,50:0', '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_AGI_GOOGLE_XML_GENDER_WORDS_MALE', 'herr,mann,herren', '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_AGI_GOOGLE_XML_GENDER_WORDS_FEMALE', 'frau,dame,damen,frauen', '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_AGI_GOOGLE_XML_GENDER_WORDS_UNISEX', 'unisex', '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_AGI_GOOGLE_XML_AGE_GROUP_WORDS_KIDS', 'kind,kinder,kids,baby', '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_AGI_GOOGLE_XML_AGE_GROUP_WORDS_ADULT', 'erwachsen,normal', '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_AGI_GOOGLE_XML_DEFAULT_CATEGORY', '', '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_AGI_GOOGLE_XML_CAMPAIGN', 'pk_campaign=google_shopping', '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_AGI_GOOGLE_XML_USE_PRODUCT_IMAGE', 'popup_images', '6', '1', 'xtc_mod_select_option(array(\'popup_images\'=>\'popup_images\', \'info_images\'=>\'info_images\'), \'MODULE_AGI_GOOGLE_XML_USE_PRODUCT_IMAGE\', ', now())");
    }
    
    $query_result = xtc_db_query("SHOW COLUMNS FROM `" . TABLE_PRODUCTS_OPTIONS . "`");
    $db_table_rows = array();
    while ($row = xtc_db_fetch_array($query_result))
      $db_table_rows[] = $row['Field'];
    
    if (!in_array('is_google_attribute', $db_table_rows))
      xtc_db_query("ALTER TABLE `" . TABLE_PRODUCTS_OPTIONS . "` ADD `is_google_attribute` VARCHAR( 64 ) NOT NULL");

    $query_result = xtc_db_query("SHOW COLUMNS FROM `" . TABLE_PRODUCTS . "`");
    $db_table_rows = array();
    while ($row = xtc_db_fetch_array($query_result))
      $db_table_rows[] = $row['Field']; 
    
    if (!in_array('agi_google_export', $db_table_rows))
    {
      $query = "ALTER TABLE `products` 
        ADD `agi_google_export` TINYINT( 1 ) NOT NULL DEFAULT '1',
        ADD `agi_google_online_only` TINYINT( 1 ) NOT NULL DEFAULT '0',
        ADD `agi_google_condition` VARCHAR( 63 ) NOT NULL DEFAULT 'new',
        ADD `agi_google_adwords_grouping` VARCHAR( 255 ) NOT NULL ,
        ADD `agi_google_adwords_labels` VARCHAR( 255 ) NOT NULL ,
        ADD `agi_google_adwords_redirect` VARCHAR( 255 ) NOT NULL ,
        ADD `agi_google_excluded_destination` VARCHAR( 63 ) NOT NULL ,
        ADD `agi_google_expiration_date` VARCHAR( 63 ) NOT NULL";
      xtc_db_query($query);
      
      $query = "ALTER TABLE `products` ADD `agi_google_products_brand` VARCHAR( 128 ) NOT NULL DEFAULT '',
        ADD `agi_google_identifier_exists` TINYINT( 1 ) NOT NULL DEFAULT '1',
        ADD `agi_google_multipack_amount` INT( 5 ) NOT NULL DEFAULT '1',
        ADD `agi_google_energy_efficiency` VARCHAR( 32 ) NOT NULL DEFAULT ''";
      xtc_db_query($query);
    }
    
    if (!in_array('google_category', $db_table_rows))
      xtc_db_query("ALTER TABLE `" . TABLE_PRODUCTS . "` ADD `google_category` TEXT NOT NULL");
      
    $query_result = xtc_db_query("SHOW COLUMNS FROM `" . TABLE_CATEGORIES . "`");
    $db_table_rows = array();
    while ($row = xtc_db_fetch_array($query_result))
      $db_table_rows[] = $row['Field']; 
      
    if (!in_array('google_category', $db_table_rows))
      xtc_db_query("ALTER TABLE `" . TABLE_CATEGORIES . "` ADD `google_category` TEXT NOT NULL");
    
    $query_result = xtc_db_query("SHOW COLUMNS FROM `" . TABLE_ADMIN_ACCESS . "`");
    $db_table_rows = array();
    while ($row = xtc_db_fetch_array($query_result))
      $db_table_rows[] = $row['Field']; 
    
    if (!in_array('google_taxonomie', $db_table_rows))
    {
      xtc_db_query("ALTER TABLE `" . TABLE_ADMIN_ACCESS . "` ADD google_taxonomie INT(1) NOT NULL DEFAULT 0");
      xtc_db_query("UPDATE `" . TABLE_ADMIN_ACCESS . "` SET `google_taxonomie` = 1 WHERE `customers_id` = 1");
    }
    
  }

  function remove() 
  {
    xtc_db_query("DELETE FROM `" . TABLE_CONFIGURATION . "` WHERE `configuration_key` IN ('" . implode("', '", $this->keys()) . "')");
  }

  function keys() 
  {
    return array(
      'MODULE_AGI_GOOGLE_XML_STATUS','MODULE_AGI_GOOGLE_XML_VPE_TITLE','MODULE_AGI_GOOGLE_XML_VPE_DESCRIPTION','MODULE_AGI_GOOGLE_CHECK_GRADUATED_PRICE',
      'MODULE_AGI_GOOGLE_XML_LONG_DESCRIPTION','MODULE_AGI_GOOGLE_XML_AVAILABILITY_FROM_QUANTITY','MODULE_AGI_GOOGLE_IGNORE_FREESHIPPING_MODULES','MODULE_AGI_GOOGLE_XML_SHIPPING_LIST',
      'MODULE_AGI_GOOGLE_XML_SHIPPING_BASE','MODULE_AGI_GOOGLE_XML_USE_PRODUCT_IMAGE','MODULE_AGI_GOOGLE_XML_GENDER_WORDS_MALE','MODULE_AGI_GOOGLE_XML_GENDER_WORDS_FEMALE',
      'MODULE_AGI_GOOGLE_XML_GENDER_WORDS_UNISEX','MODULE_AGI_GOOGLE_XML_AGE_GROUP_WORDS_KIDS','MODULE_AGI_GOOGLE_XML_AGE_GROUP_WORDS_ADULT',
      'MODULE_AGI_GOOGLE_XML_DEFAULT_CATEGORY','MODULE_AGI_GOOGLE_XML_CAMPAIGN'
    );
  }
  
  function do_modul_updates()
  {
    // update itself
    // to version s1.2
    if (!defined('MODULE_AGI_GOOGLE_CHECK_GRADUATED_PRICE'))
      xtc_db_query("INSERT INTO `" . TABLE_CONFIGURATION . "` (`configuration_key`, `configuration_value`, `configuration_group_id`, `sort_order`, `set_function`, `date_added`) VALUES ('MODULE_AGI_GOOGLE_CHECK_GRADUATED_PRICE', 'FALSE', '6', '1', 'xtc_cfg_select_option(array(\'TRUE\', \'FALSE\'), ', now())");
    if (!defined('MODULE_AGI_GOOGLE_IGNORE_FREESHIPPING_MODULES'))
      xtc_db_query("INSERT INTO `" . TABLE_CONFIGURATION . "` (`configuration_key`, `configuration_value`, `configuration_group_id`, `sort_order`, `set_function`, `date_added`) VALUES ('MODULE_AGI_GOOGLE_IGNORE_FREESHIPPING_MODULES', 'FALSE', '6', '1', 'xtc_cfg_select_option(array(\'TRUE\', \'FALSE\'), ', now())");
    
    // update to 1.4 S and P
    if (!defined('MODULE_AGI_GOOGLE_XML_USE_PRODUCT_IMAGE'))
    {
      // modul-Konfiguration
      xtc_db_query("INSERT INTO `" . TABLE_CONFIGURATION . "` (`configuration_key`, `configuration_value`, `configuration_group_id`, `sort_order`, `set_function`, `date_added`) VALUES ('MODULE_AGI_GOOGLE_XML_USE_PRODUCT_IMAGE', 'popup_images', '6', '1', 'xtc_mod_select_option(array(\'popup_images\'=>\'popup_images\', \'info_images\'=>\'info_images\'), \'MODULE_AGI_GOOGLE_XML_USE_PRODUCT_IMAGE\', ', now())");
      // neue Produktwerte
      $query = "ALTER TABLE `products` ADD `agi_google_products_brand` VARCHAR( 128 ) NOT NULL DEFAULT '',
        ADD `agi_google_identifier_exists` TINYINT( 1 ) NOT NULL DEFAULT '1',
        ADD `agi_google_multipack_amount` INT( 5 ) NOT NULL DEFAULT '1',
        ADD `agi_google_energy_efficiency` VARCHAR( 32 ) NOT NULL DEFAULT ''";
      xtc_db_query($query);
      $query = "UPDATE `products` SET `agi_google_identifier_exists`=1";
      xtc_db_query($query);
    }
  }
}
?>
Infolge der länge dieser Einbauanleitung, muss ich den Beitrag in 3 Teile aufteilen. Die Fortsetzung folgt gleich im nächsten Beitrag
Zuletzt geändert von Kopernikus am So 30. Jun 2013, 11:47, insgesamt 4-mal geändert.
Kopernikus
Beiträge: 390
Registriert: Fr 19. Okt 2012, 12:15

Re: Modul Einbauanleitung: Google Merchant Center inkl Taxon

Beitrag von Kopernikus »

Fortsetzung TEIL 2

/export/google_xml.php
WICHTIG!: Diese Datei muss Schreib und Leserechte erhalten (777)

Code: Alles auswählen

<?php
/* export/google_xml.php
.---------------------------------------------------------------------------.
|    Software: GOOGLE-Shopping XML-Export for modified-shops and xt:c 3     |
|      Author: Andreas Guder                                                |
|     Version: 1.5 Standard                                                 |
|     Contact: info@andreas-guder.de / http://www.andreas-guder.de          |
| Copyright (c) 2013, Andreas Guder [info@andreas-guder.de]                 |
|               GNU General Public License  (Version 3)                     |
'--------------------------------------------------------------------------ö'
*/
require '../includes/configure.php';
error_reporting(E_ALL ^E_DEPRECATED ^E_NOTICE);
$cache_days       = 0; // number of days, the xml-file will be cached before 
$export_language  = 2; // GET['lang'] language-id to export
$export_group     = 1; // GET['group'] customers-group
$limit_page       = 0; // GET['page'] number of page to export, empty or not set to export the whole database 
$limit_amount     = 5000; // amount of article to export if GET['page'] is set
$country_id       = 0; // GET['country'] country-id, will be get shop-country-id if empty
$zone_id          = 0; // GET['zone'] zone-id, will be get shop-zone-id if empty

define('LN',chr(10));

if (isset($_GET['lang']) && !empty($_GET['lang']))
  $export_language = (int) $_GET['lang'];
  
if (isset($_GET['group']) && !empty($_GET['group']))
  $export_group = (int) $_GET['group'];

if (isset($_GET['page']) && !empty($_GET['page']))
  $limit_page = (int) $_GET['page'];
  
if (isset($_GET['cache']))
  $cache_days = (int) $_GET['cache'];
  
if (isset($_GET['country']))
  $country_id = (int) $_GET['country'];

if (isset($_GET['zone']))
  $zone_id = (int) $_GET['zone'];

$cache_file_name = 'google_xml_l'.$export_language.'_g'.$export_group.'_p'.$limit_page.'_'.$country_id.$zone_id.'.xml';
define('CACHED_GOOGLE_FILE', DIR_FS_CATALOG.'export/'.$cache_file_name);

// check cache
if ($cache_days > 0)
{
  if (file_exists(CACHED_GOOGLE_FILE))
  {
    if (time()-filemtime(CACHED_GOOGLE_FILE) < $cache_days * 24 * 3600)
    {
      // print out cached file
      header("Content-Type: text/xml");
      echo file_get_contents(CACHED_GOOGLE_FILE);
      exit;
    }
  }
}

session_start();
$_SESSION['languages_id'] = $export_language;

require DIR_WS_INCLUDES.'database_tables.php';
require DIR_WS_INCLUDES.'filenames.php';

// require some functions anc classes
// Database
require_once (DIR_FS_INC.'xtc_db_set_charset.inc.php');
require_once (DIR_FS_INC.'xtc_db_connect.inc.php');
require_once (DIR_FS_INC.'xtc_db_close.inc.php');
require_once (DIR_FS_INC.'xtc_db_error.inc.php');
require_once (DIR_FS_INC.'xtc_db_perform.inc.php');
require_once (DIR_FS_INC.'xtc_db_query.inc.php');
require_once (DIR_FS_INC.'xtc_db_queryCached.inc.php');
require_once (DIR_FS_INC.'xtc_db_fetch_array.inc.php');
require_once (DIR_FS_INC.'xtc_db_num_rows.inc.php');
require_once (DIR_FS_INC.'xtc_db_data_seek.inc.php');
require_once (DIR_FS_INC.'xtc_db_insert_id.inc.php');
require_once (DIR_FS_INC.'xtc_db_free_result.inc.php');
require_once (DIR_FS_INC.'xtc_db_fetch_fields.inc.php');
require_once (DIR_FS_INC.'xtc_db_output.inc.php');
require_once (DIR_FS_INC.'xtc_db_input.inc.php');
require_once (DIR_FS_INC.'xtc_db_prepare_input.inc.php');
require_once (DIR_FS_INC.'xtc_get_top_level_domain.inc.php');
require_once (DIR_FS_INC.'xtc_href_link.inc.php');
require_once (DIR_FS_INC.'xtc_product_link.inc.php');
require_once (DIR_FS_INC.'xtc_category_link.inc.php');
require_once (DIR_FS_INC.'xtc_get_category_path.inc.php');
require_once (DIR_FS_INC.'xtc_get_parent_categories.inc.php');
require_once (DIR_FS_INC.'xtc_image.inc.php');
require_once (DIR_FS_INC.'xtc_get_tax_rate.inc.php');
require_once (DIR_FS_INC.'xtc_add_tax.inc.php');
require_once (DIR_FS_INC.'xtc_cleanName.inc.php');
//require_once (DIR_FS_INC.'xtc_get_products_mo_images.inc.php');
require_once (DIR_FS_INC.'xtc_set_time_limit.inc.php');
require_once (DIR_FS_INC.'xtc_parse_category_path.inc.php');
require_once (DIR_FS_INC.'xtc_get_product_path.inc.php');

require_once (DIR_FS_INC.'ecb_substr.inc.php');
require_once (DIR_FS_INC.'ecb_strlen.inc.php');
@xtc_set_time_limit(0);

// old functions
function xtDBquery($query) {
	if (strtolower(DB_CACHE) == 'true') {
//			echo  'cached query: '.$query.'<br />';
		$result = xtc_db_queryCached($query);
	} else {
//				echo '::'.$query .'<br />';
		$result = xtc_db_query($query);

	}
	return $result;
}

// make a connection to the database... now
$connection = xtc_db_connect() or die('Unable to connect to database server!');

$configuration_query = xtc_db_query('select configuration_key as cfgKey, configuration_value as cfgValue from '.TABLE_CONFIGURATION);
while ($configuration = xtc_db_fetch_array($configuration_query)) {
	define($configuration['cfgKey'], $configuration['cfgValue']);
}

if (!defined('MODULE_AGI_GOOGLE_CHECK_GRADUATED_PRICE'))
  define('MODULE_AGI_GOOGLE_CHECK_GRADUATED_PRICE', 'FALSE');
if (!defined('MODULE_AGI_GOOGLE_IGNORE_FREESHIPPING_MODULES'))
  define('MODULE_AGI_GOOGLE_IGNORE_FREESHIPPING_MODULES', 'FALSE');

if (!defined('MODULE_AGI_GOOGLE_XML_STATUS') || MODULE_AGI_GOOGLE_XML_STATUS != 'TRUE')
{
  header("HTTP/1.0 403 Forbidden");
  exit;
}

// prepare own functions
$temp_category = array(0=>'Top');
$temp_tax = array();
$vpe_names= array();
$brand_names= array();
$google_cat=array(0=>MODULE_AGI_GOOGLE_XML_DEFAULT_CATEGORY);
function buildCAT($catID, $export_language = 2)
{
  $cat=array();
  $tmpID=$catID;
  while (getParent($catID)!=0 || $catID!=0)
  {
    $cat_select=xtc_db_query("SELECT `categories_name` FROM ".TABLE_CATEGORIES_DESCRIPTION." WHERE `categories_id`='".$catID."' AND `language_id`=$export_language");
    $cat_data=xtc_db_fetch_array($cat_select);
    $catID=getParent($catID);
    $cat[]=$cat_data['categories_name'];
  }
  $catStr='';
  for ($i=count($cat);$i>0;$i--)
  {
    $catStr.= ($i > 1) ? $cat[$i-1].' > ' : $cat[$i-1];
  }
  return $catStr;
}
function getParent($catID)
{
  $parent_query=xtc_db_query("SELECT `parent_id` FROM `".TABLE_CATEGORIES."` WHERE `categories_id`='".$catID."'");
  $parent_data=xtc_db_fetch_array($parent_query);
  return  $parent_data['parent_id'];
}
function getCategory($pID)
{
  $categories = 0;
  $categorie_query=xtc_db_query("SELECT `categories_id` FROM `".TABLE_PRODUCTS_TO_CATEGORIES."` WHERE `categories_id` > 0 AND `products_id`='".$pID."' LIMIT 0,1");
  while ($categorie_data=xtc_db_fetch_array($categorie_query)) {
    $categories=$categorie_data['categories_id'];
  }
  return $categories;
}
function getGoogleCategory($catID)
{
  $parent_query = xtc_db_query("SELECT `parent_id`,`google_category` FROM `".TABLE_CATEGORIES."` WHERE `categories_id`='".$catID."'");
  $parent_data  = xtc_db_fetch_array($parent_query);
  while (empty($parent_data['google_category']) && $parent_data['parent_id'] > 0)
  {
    $parent_query = xtc_db_query("SELECT `parent_id`,`google_category` FROM `".TABLE_CATEGORIES."` WHERE `categories_id`='".$parent_data['parent_id']."'");
    $parent_data  = xtc_db_fetch_array($parent_query);
  }
  return empty($parent_data['google_category']) ? '' : $parent_data['google_category'];
}
function explode_vpe_parts($vpe_text)
{
  $vpe_parts = array('value' => 1, 'unit' => 'Stck.');
  if (preg_match('/[0-9]{1,}/', $vpe_text, $matches))
  {
    $vpe_parts['value'] = $matches[0];
    $vpe_parts['unit'] = trim(substr($vpe_text, strlen($vpe_parts['value'])));
  }
  else
    $vpe_parts['unit'] = trim($vpe_text);
  settype($vpe_parts['value'], 'integer');
  return $vpe_parts;
}
function get_vpe_name($vpeID, $export_language = 2) 
{
  $vpe_query="SELECT `products_vpe_name` FROM `" . TABLE_PRODUCTS_VPE . "` WHERE `language_id`=$export_language AND `products_vpe_id`='".$vpeID."'";
  $vpe_query = xtDBquery($vpe_query);
  $vpe = xtc_db_fetch_array($vpe_query,true);
  
  $tmp = array('name'=>$vpe['products_vpe_name'], 'parts' => explode_vpe_parts($vpe['products_vpe_name']));
  return $tmp;

}
function get_brand_name($manID) 
{
  $marke = xtc_db_fetch_array(xtc_db_query("SELECT `manufacturers_name` FROM `".TABLE_MANUFACTURERS."` WHERE `manufacturers_id` = '".$manID."'"));
  return $marke['manufacturers_name'];
}
function cartesian_helper($sofar,$arr,$pos,$max,&$collector)
{
  $tmp = array_keys($arr);
  for($i = 0; $i < count($arr[$tmp[$pos]]);$i++)
  {
    if($pos == $max)
      $collector[] = array_merge($sofar,array($arr[$tmp[$pos]][$i]));
    else
      cartesian_helper(array_merge($sofar,array($arr[$tmp[$pos]][$i])),$arr,$pos+1,$max,$collector);
  }
}
function cartesian($arr)
{
  $bucket = array();
  cartesian_helper(array(),$arr,0,count($arr)-1,$bucket);
  return $bucket;
}
function calculate_shipping_from_table($s_price, $s_weight)
{
  $shipping = -1;
  $shippinglist = preg_split("/[:,]/" , MODULE_AGI_GOOGLE_XML_SHIPPING_LIST);
  $base = (MODULE_AGI_GOOGLE_XML_SHIPPING_BASE == 'weight') ? $s_weight : $s_price;
  for ($i=0; $i<sizeof($shippinglist); $i+=2) 
  {
    if ($base <= $shippinglist[$i]) 
    {
      $shipping = $shippinglist[$i+1];
      break;
    }
  }
  if ($shipping == -1)
    $shipping = 0;
  return $shipping;
}
function clean_html_to_text($text, $short = 0)
{
  $find     = array('</p>', '<br />', '<li />', '>');
  $replace  = array('</p>'.chr(10), '<br />'.chr(10), '</li>'.chr(10), '> ');
  $text = str_replace($find, $replace, $text);
  $cleared_text = strip_tags($text);
  $cleared_text = html_entity_decode($cleared_text,ENT_QUOTES,'UTF-8');
  $cleared_text = str_replace("&nbsp;"," ",$cleared_text);
  $cleared_text = str_replace("'",", ",$cleared_text);
  $cleared_text = str_replace("\n"," ",$cleared_text);
  $cleared_text = str_replace("\r"," ",$cleared_text);
  $cleared_text = str_replace("\t"," ",$cleared_text);
  $cleared_text = str_replace("\v"," ",$cleared_text);
  $cleared_text = str_replace("|",",",$cleared_text);
  $cleared_text = preg_replace("/ {2,}/"," ",$cleared_text);
  if ($short > 0)
  {
    $shorten = wordwrap($cleared_text, $short, "|");
    $shorten = explode("|", $shorten);
    $cleared_text = $shorten[0];
  }
  
  $cleared_text = trim($cleared_text);
  return $cleared_text;
}
function get_webs_images($pid, $export_language = 2)
{
  $sql = 'SELECT ip.prd_id, ip.img_id, i.img_md5, i.img_type, ipd.alt, ipd.title, ipd.description
    FROM image_product ip
    JOIN image i using (img_id)
    LEFT JOIN image_product_description ipd
        ON ip.img_prd_id = ipd.img_prd_id AND ipd.lng_id = ' . (int) $export_language . '
    WHERE
      ip.prd_id = ' . (int) $pid . ' AND
      ip.sort_order = 0';
  $res = xtc_db_query($sql);
  
  $images = array();

  while ( $row = xtc_db_fetch_array($res) ) {
    $images[] = array(
      'ID' => $row['img_id'],
      'ALT' => $row['alt'],
      'TITLE' => $row['title'],
      'DESC' => $row['description'],
      'MD5' => $row['img_md5'],
      'FILE' => $row['img_md5'] . '.' . $row['img_type'],
      'TYPE' => $row['img_type']
    );
  }
  return $images;
}
function get_webs_image_name($alt, $products_name)
{
  $search = array (
    '|ä|',
    '|ö|',
    '|ü|',
    '|ß|'
  );
  $replace = array (
    '|ae|',
    '|oe|',
    '|ue|',
    '|ss|'
  );
  $data = empty($alt) ? $products_name : $alt;
  $data = trim(strtolower($data));
  $data  = preg_replace($search, $replace, $data);
  $data = str_replace(' ', '-', $data);
  $data = preg_replace('/[^a-z0-9\-]/', '', $data);
  return $data;
}
function print_out_xml_item($key, $value)
{
  if (is_string($value) && ($value != 'TRUE' || $value != 'FALSE'))
    echo '<',$key,'><![CDATA[',$value,']]></',$key,'>',LN;
  else
    echo '<',$key,'>',$value,'</',$key,'>',LN;
}
function print_out_product($products_data)
{
  $products_description = strtolower(MODULE_AGI_GOOGLE_XML_LONG_DESCRIPTION) == 'true' ? $products_data['products_description'] : $products_data['products_short_description'];
  $products_description = clean_html_to_text($products_description);
  $products_name = $products_data['products_name'];
  
  if (!empty($products_data['vpe']))
  {
    if (strtolower(MODULE_AGI_GOOGLE_XML_VPE_TITLE) == 'true')
      $products_name .= ' ('.$products_data['vpe'].')';
    if (strtolower(MODULE_AGI_GOOGLE_XML_VPE_DESCRIPTION) == 'true')
      $products_description = '('.$products_data['vpe'].') '.$products_description;
  }
  
  // check condition
  $condition = 'new';
  if (empty($products_data['agi_google_condition']))
  {
    if (!empty($products_data['products_zustand']))
    {
      switch ($products_data['products_zustand'])
      {
        case 'neu':
        case 'new':
          $condition = 'new';
          break;
        case 'gebraucht':
        case 'used':
          $condition = 'used';
          break;
        case 'erneuert':
        case 'refurbished':
          $condition = 'refurbished';
          break;
        default: $condition = 'new'; break;
      }
    }
  }
  else
    $condition = $products_data['agi_google_condition'];
    
  // check availability
  $availability = 'in stock';
  if (strtolower(MODULE_AGI_GOOGLE_XML_AVAILABILITY_FROM_QUANTITY) == 'true')
  {
    if ($products_data['products_quantity'] <= 0)
      $availability = 'out of stock';
  }
  
  // calculate shipping
  $s_price = $products_data['products_price'];
  if ($products_data['product_has_special']) 
    $s_price = $products_data['specials_new_products_price'];
  $shipping = 0;
  if (strtolower(MODULE_AGI_GOOGLE_IGNORE_FREESHIPPING_MODULES) == 'true')
  {
    $shipping = calculate_shipping_from_table($s_price, $products_data['products_weight']);
  }
  else
  {
    if (defined('MODULE_SHIPPING_FREEAMOUNT_AMOUNT') && defined('MODULE_SHIPPING_FREEAMOUNT_STATUS') && strtolower(MODULE_SHIPPING_FREEAMOUNT_STATUS) == 'true' && $s_price >= MODULE_SHIPPING_FREEAMOUNT_AMOUNT)
      $shipping = 0;
    elseif (defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER') && strtolower(MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING) == 'true' && $s_price > MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER)
      $shipping = 0;
    else
      $shipping = calculate_shipping_from_table($s_price, $products_data['products_weight']);
  }
  
  echo '<item>',LN;
  print_out_xml_item('title', $products_name);
  print_out_xml_item('description', $products_description);
  if (array_key_exists('agi_google_adwords_redirect', $products_data) && !empty($products_data['agi_google_adwords_redirect']))
    print_out_xml_item('link', $products_data['agi_google_adwords_redirect']);
  else
    print_out_xml_item('link', $products_data['link']);
  print_out_xml_item('g:id', $products_data['products_id']);
  if (!empty($products_data['item_group_id']))
    print_out_xml_item('g:item_group_id', $products_data['item_group_id']);
  print_out_xml_item('g:google_product_category', $products_data['google_category']);
  print_out_xml_item('g:product_type', $products_data['category']);
  /* webs */
  $image_dir = 'pictures/popup/';
  if (defined('MODULE_AGI_GOOGLE_XML_USE_PRODUCT_IMAGE') && MODULE_AGI_GOOGLE_XML_USE_PRODUCT_IMAGE == 'info_images')
    $image_dir = 'pictures/info/';
  if (!empty($products_data['products_images']))
  {
    $img = current($products_data['products_images']);
    print_out_xml_item('g:image_link', HTTP_SERVER . DIR_WS_CATALOG . $image_dir . $img['ID'] . '/' . get_webs_image_name($img['ALT'], $products_data['products_name']) . '.' .$img['TYPE']);
  }
  
  $i_count = 0;
  while($img = next($products_data['products_images']))
  {
    print_out_xml_item('g:additional_image_link', HTTP_SERVER . DIR_WS_CATALOG . $image_dir . $img['ID'] . '/' . get_webs_image_name($img['ALT'], $products_data['products_name']) . '.' .$img['TYPE']);
    $i_count++;
    if ($i_count >= 10)
      break;
  }
  /* webs */
  print_out_xml_item('g:condition', $condition);
  
  print_out_xml_item('g:availability', $availability);
  print_out_xml_item('g:price', number_format($products_data['products_price'],2,'.','').' '.DEFAULT_CURRENCY);
  if ($products_data['product_has_special'])
  {
    print_out_xml_item('g:sale_price', number_format($products_data['specials_new_products_price'],2,'.','').' '.DEFAULT_CURRENCY);
    if (!empty($products_data['special_expires_date']))
    {
      $tmp = strtotime($products_data['special_expires_date'].' +1 day');
      if ($tmp > 0)
        print_out_xml_item('g:sale_price_effective_date', date('Y-m-d').'T00:00'.date('O').'/'.date('Y-m-d',$tmp).'T'.date('H:iO',$tmp));
    }
  }

  if ($products_data['agi_google_identifier_exists'])
    print_out_xml_item('g:brand', empty($products_data['brand']) ? 'Hausmarke' : $products_data['brand']);
  else
    print_out_xml_item('g:brand', $products_data['brand']);
  
  if ($products_data['agi_google_identifier_exists'])
  {
    if (!empty($products_data['products_ean']))
      print_out_xml_item('g:gtin', $products_data['products_ean']);
  }
  else
    print_out_xml_item('g:identifier_exists', 'FALSE');
  print_out_xml_item('g:mpn', !empty($products_data['products_manufacturers_model']) ? $products_data['products_manufacturers_model'] : $products_data['products_model']);
   
  
  echo '<g:shipping>',LN;
    print_out_xml_item('g:country', COUNTRY_CODE);
    print_out_xml_item('g:service', $shipping > 0 ? 'Standard' : 'Versandkostenfrei');
    print_out_xml_item('g:price', number_format($shipping,2,'.','').' '.DEFAULT_CURRENCY);
  echo '</g:shipping>',LN;
  
  if (!empty($products_data['products_weight']))
    print_out_xml_item('g:shipping_weight', number_format($products_data['products_weight'],3,'.',''). 'kg');
  
  if (!empty($products_data['agi_google_energy_efficiency']))
    print_out_xml_item('g:energy_efficiency_class', $products_data['agi_google_energy_efficiency']);
  
  if ($products_data['products_fsk18'])
    print_out_xml_item('g:adult', 'TRUE');
    
  if ($products_data['agi_google_multipack_amount'] > 1)
    print_out_xml_item('g:multipack', $products_data['agi_google_multipack_amount']);
    
  if (!empty($products_data['vpe']))
  {
    print_out_xml_item('g:unit_pricing_measure', $products_data['unit_pricing_measure']);
    print_out_xml_item('g:unit_pricing_base_measure', $products_data['unit_pricing_base_measure']);
  }
  
  
  if (array_key_exists('agi_google_adwords_grouping', $products_data) && !empty($products_data['agi_google_adwords_grouping']))
    print_out_xml_item('g:adwords_grouping', $products_data['agi_google_adwords_grouping']);
  
  if (array_key_exists('agi_google_adwords_labels', $products_data) && !empty($products_data['agi_google_adwords_labels']))
  {
    $tmp = explode(',',$products_data['agi_google_adwords_labels']);
    foreach ($tmp as $row)
    {
      $row = trim($row);
      if (!empty($row))
        print_out_xml_item('g:adwords_labels', $row);
    }
  }
  
  if (array_key_exists('agi_google_adwords_redirect', $products_data) && !empty($products_data['agi_google_adwords_redirect']))
    print_out_xml_item('g:adwords_redirect', $products_data['agi_google_adwords_redirect']);
  
  if (array_key_exists('agi_google_online_only', $products_data))
    print_out_xml_item('g:online_only', $products_data['agi_google_online_only'] ? 'y' : 'n');
  
  if (array_key_exists('agi_google_excluded_destination', $products_data) && !empty($products_data['agi_google_excluded_destination']))
    print_out_xml_item('g:excluded_destination', $products_data['agi_google_excluded_destination']);
  
  if (array_key_exists('agi_google_expiration_date', $products_data) && !empty($products_data['agi_google_expiration_date']))
    print_out_xml_item('g:expiration_date', $products_data['agi_google_expiration_date']);
  
  echo '</item>',LN;
}

$tmp_bluegate = false;
if (defined('MODULE_BLUEGATE_SEO_INDEX_STATUS') && file_exists(DIR_FS_CATALOG.'inc/bluegate_seo.inc.php'))
{
  if (strtolower(MODULE_BLUEGATE_SEO_INDEX_STATUS) == 'true')
  {
    require_once(DIR_FS_CATALOG.'inc/bluegate_seo.inc.php');
    $bluegateSeo = new BluegateSeo();
    $tmp_bluegate = true;
  }
}
define('USE_BLUEGATE_SEO_URL',$tmp_bluegate);

// get google-attributes-options
$google_attribute_options = array();
$google_attribute_options_ids = array();
$google_attribute_options_ids_name = array();

// get customers_status
$c_check = xtc_db_query("SELECT * FROM `".TABLE_CUSTOMERS_STATUS."` WHERE `customers_status_id`=$export_group AND `language_id`=$export_language");
if (xtc_db_num_rows($c_check) == 0)
  $c_check = xtc_db_query("SELECT * FROM `".TABLE_CUSTOMERS_STATUS."` WHERE `customers_status_id`=1 AND `language_id`=1");
$customers_status = xtc_db_fetch_array($c_check);

// get country-id if not set by GET
if (empty($country_id))
  $country_id = STORE_COUNTRY;
if (empty($zone_id))
  $zone_id = STORE_ZONE;
if (empty($zone_id) && !empty($country_id))
{
  $tmp = xtc_db_query("SELECT `zone_id` FROM `".TABLE_ZONES."` WHERE `zone_country_id`=$country_id LIMIT 0,1");
  $tmp = xtc_db_fetch_array($tmp);
  $zone_id = $tmp['zone_id'];
}
$currency_code = DEFAULT_CURRENCY;

$tmp = xtc_db_query("SELECT `countries_iso_code_2` FROM `".TABLE_COUNTRIES."` WHERE `countries_id`=$country_id LIMIT 0,1");
$tmp = xtc_db_fetch_array($tmp);
if (!$tmp)
  $tmp['countries_iso_code_2'] = 'DE';
define('COUNTRY_CODE',$tmp['countries_iso_code_2']);


// Prepare general database query
$general_query = "SELECT 
    p.*, 
    pd.products_short_description, 
    pd.products_name, 
    pd.products_description,
    IFNULL(s.status, 0) AS product_has_special,
    IFNULL(s.specials_new_products_price, 0) AS specials_new_products_price,
    IFNULL(s.expires_date,'') AS special_expires_date
  FROM 
    `".TABLE_PRODUCTS."` AS p
    LEFT JOIN `".TABLE_PRODUCTS_DESCRIPTION."` AS pd ON pd.products_id=p.products_id AND pd.language_id=$export_language
    LEFT JOIN `".TABLE_SPECIALS."` AS s ON s.products_id=p.products_id
  WHERE 
    p.products_status=1 AND p.agi_google_export=1 
  ";

if (strtolower(GROUP_CHECK) == 'true')
  $general_query .= " AND p.group_permission_$export_group=1";

// Export FSK-Article?
if (!$customers_status['customers_fsk18_display'])
  $general_query .= ' AND p.products_fsk18!=1';

// GROUP BY ORDER BY
$general_query .= ' ORDER BY p.products_id ASC';

// Export-Limit ?
if ($limit_page > 0)
{
  $lstart = ($limit_page-1) * $limit_amount;
  $general_query .= " LIMIT $lstart, $limit_amount";
}

$main_product_query = xtc_db_query($general_query);
$tmp = xtc_db_num_rows($main_product_query);

if (empty($tmp))
{
  header("HTTP/1.0 204 No Content");
  exit;
}

// Start OUTPUT
// start caching
ob_start();

echo '<?xml version="1.0" encoding="UTF-8"?>'.LN;
echo '<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">'.LN;
echo '<channel>',LN;
echo '<title><![CDATA[',STORE_NAME,']]></title>',LN;
echo '<link><![CDATA[',HTTP_SERVER,']]></link>',LN;
echo '<description><![CDATA[Google product feed created at ',date('Y-m-d H:i'),']]></description>',LN;

while ($listing = xtc_db_fetch_array($main_product_query))
{
  //if (empty($listing['products_image']))
  $listing['products_images'] = get_webs_images($listing['products_id']);
  if (empty($listing['products_images'])) // webs
    continue;
  
  $allready_print_out = false;
  if (!array_key_exists($listing['products_tax_class_id'], $temp_tax))
    $temp_tax[$listing['products_tax_class_id']] = xtc_get_tax_rate($listing['products_tax_class_id'], $country_id, $zone_id);
  
  if($listing['product_has_special'] && !empty($listing['special_expires_date']))
  {
    $tmp = strtotime($listing['special_expires_date']);
    if ($tmp < time() && $tmp>0)
      $listing['product_has_special'] = 0;
    if ($listing['products_price']<$listing['specials_new_products_price'])
      $listing['product_has_special'] = 0;
  }
  
  // personal offer?
  /*
  if ($customers_status['customers_status_graduated_prices'] && strtolower(MODULE_AGI_GOOGLE_CHECK_GRADUATED_PRICE) == 'true')
  {
    $offer_check = xtc_db_query("SELECT `personal_offer` FROM `".TABLE_PERSONAL_OFFERS_BY.$export_group."` WHERE `products_id`=".$listing['products_id']." AND `personal_offer`>0 ORDER BY `quantity` DESC LIMIT 0,1");
    if (xtc_db_num_rows($offer_check) == 1)
    {
      $tmp = xtc_db_fetch_array($offer_check);
      if (!empty($tmp['personal_offer']))
        $listing['products_price'] = $tmp['personal_offer'];
    }
  }
  */
  if ($customers_status['customers_status_show_price_tax'])
  {
    $listing['products_price'] = xtc_add_tax($listing['products_price'], $temp_tax[$listing['products_tax_class_id']]);
    $listing['specials_new_products_price'] = xtc_add_tax($listing['specials_new_products_price'], $temp_tax[$listing['products_tax_class_id']]);
  }
  
  $products_data = $listing;
  
  $products_data['link'] = USE_BLUEGATE_SEO_URL ? $bluegateSeo->getProductLink(xtc_product_link($listing['products_id'], $listing['products_name']),'NONSSL',$export_language) : xtc_href_link(FILENAME_PRODUCT_INFO, xtc_product_link($listing['products_id'],$listing['products_name']),'NONSSL', false);
  if (MODULE_AGI_GOOGLE_XML_CAMPAIGN != '')
    $products_data['link'] .= strpos($products_data['link'], '?') ? '&'.MODULE_AGI_GOOGLE_XML_CAMPAIGN : '?'.MODULE_AGI_GOOGLE_XML_CAMPAIGN;
  
  if ($listing['products_vpe_status'] == 1 && $listing['products_vpe_value'] != 0.0 && $listing['products_price'] > 0)
  {
    if (!array_key_exists($listing['products_vpe'],$vpe_names))
      $vpe_names[$listing['products_vpe']] = get_vpe_name($listing['products_vpe'], $export_language);
    $tmp_price = $listing['product_has_special'] ? $listing['specials_new_products_price'] : $listing['products_price'];
    $vpe_price = number_format($tmp_price * (1 / $listing['products_vpe_value']), 2,',','').' '.$currency_code.' pro '.$vpe_names[$listing['products_vpe']]['name'];
    $products_data['vpe'] = $vpe_price;
    
    $tmp = round($vpe_names[$listing['products_vpe']]['parts']['value']*$listing['products_vpe_value'],3);
    $products_data['unit_pricing_measure']      = $tmp.$vpe_names[$listing['products_vpe']]['parts']['unit'];
    $products_data['unit_pricing_base_measure'] = $vpe_names[$listing['products_vpe']]['parts']['value'].$vpe_names[$listing['products_vpe']]['parts']['unit'];
  }
  
  if (!empty($listing['manufacturers_id']) && !array_key_exists($listing['manufacturers_id'], $brand_names))
    $brand_names[$listing['manufacturers_id']] = get_brand_name($listing['manufacturers_id'], $export_language);
  $products_data['brand'] = !empty($listing['manufacturers_id']) ? $brand_names[$listing['manufacturers_id']] : '';
  if (!empty($products_data['agi_google_products_brand']))
    $products_data['brand'] = $products_data['agi_google_products_brand'];
  
  $pCategory = getCategory($listing['products_id']);
  if (empty($pCategory))
    $pCategory = 0;
  if (!array_key_exists($pCategory, $temp_category))
    $temp_category[$pCategory] = buildCAT($pCategory);
  $products_data['category'] = $temp_category[$pCategory];
  
  if (!empty($pCategory))
  {
    if (!array_key_exists($pCategory, $google_cat))
    {
      $tmp = getGoogleCategory($pCategory);
      $google_cat[$pCategory] = empty($tmp) ? MODULE_AGI_GOOGLE_XML_DEFAULT_CATEGORY : $tmp;
    }
  }
  else
    $pCategory = 0;
  $use_google_category = MODULE_AGI_GOOGLE_XML_DEFAULT_CATEGORY;
  if (!empty($listing['google_category']))
    $use_google_category = $listing['google_category'];
  elseif (!empty($google_cat[$pCategory]))
    $use_google_category = $google_cat[$pCategory];
  $products_data['google_category'] = $use_google_category;
  
  $products_data['additional_image'] = array();
  /*
  $images = xtc_get_products_mo_images($listing['products_id']);
	if ($images) 
  {
    foreach($images as $image) {
      $products_data['additional_image'][] = $image['image_name'];
    }
	}
  */
  
  if (!$allready_print_out)
  {
    // Produkt hier ausgeben
    if (defined('SHIPPING_BOX_WEIGHT'))
      $products_data['products_weight'] += SHIPPING_BOX_WEIGHT;
      
    // print out products data
    print_out_product($products_data);
  }
}

echo '</channel>',LN;
echo '</rss>';

// END OUTPUT
// end caching

$content = ob_get_clean();

// save cache
$fp = fopen(CACHED_GOOGLE_FILE,'w');
fputs($fp, $content);
fclose($fp);

// show cached content
header("Content-Type: text/xml");
echo $content;

?>
Geänderte Dateien:

/admin/categories.php

-----------------------
suche:
-----------------------

Code: Alles auswählen

// --- MULTI COPY ENDS ---
-----------------------
darunter einfügen:
-----------------------

Code: Alles auswählen

 /** BOF AGI GOOGLE-ADWORDS-EXPORT www.andreas-guder.de */
      // multi_google_category confirm/select
      if (isset ($_POST['multi_g_taxonomie_confirm'])) {
        if (xtc_not_null($_POST['google_multi_category']))
        {
          $dest_google_category = xtc_db_prepare_input($_POST['google_multi_category']);
          if (!empty($_POST['multi_products']))
          {
            foreach ($_POST['multi_products'] AS $product_id) {
              xtc_db_query("UPDATE ".TABLE_PRODUCTS." SET `google_category`='".$dest_google_category."' WHERE products_id = '".xtc_db_input($product_id)."'");
            }
          }
          if (!empty($_POST['multi_categories']))
          {
            foreach ($_POST['multi_categories'] AS $category_id) {
              xtc_db_query("UPDATE ".TABLE_CATEGORIES." SET `google_category`='".$dest_google_category."' WHERE categories_id = '".xtc_db_input($category_id)."'");
            }
          }
        }
      }
      /** EOF AGI GOOGLE-ADWORDS-EXPORT www.andreas-guder.de */
Ende Teil 2 - Es geht gleich weiter mit Teil 3
Zuletzt geändert von Kopernikus am So 30. Jun 2013, 11:50, insgesamt 2-mal geändert.
Kopernikus
Beiträge: 390
Registriert: Fr 19. Okt 2012, 12:15

Re: Modul Einbauanleitung: Google Merchant Center inkl Taxon

Beitrag von Kopernikus »

Fortsetzung TEIL 3

/admin/includes/header.php

----------------------------------------
Suche
----------------------------------------

Code: Alles auswählen

 BOX_IMPORT => array('acl' => 'csv_backend',
                        'link' => 'csv_backend.php',
                        'icon' => 'icon_in-export.png'),
---------------------------------------
Füge gleich danach ein
---------------------------------------

Code: Alles auswählen

    BOX_GOOGLE_TAXONOMIE => array('acl' => 'google_taxonomie',
                        'link' => 'google_taxonomie.php',
                        'icon' => 'icon_in-export.png'),
/admin/includes/stylesheet.css:
-----------------------
am Ende einfügen:
-----------------------

Code: Alles auswählen

 /** BOF AGI GOOGLE-ADWORDS-EXPORT www.andreas-guder.de */
  #g_taxonomie_select { width: auto; margin-left: 15px; z-index: 100; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 15px; }
  #g_taxonomie_select ul { list-style-type: none; margin: 0; padding: 0;}
  #g_taxonomie_select li { position: relative; display: block; width: 250px; margin: 0px; padding: 2px 0 2px 2px; background-color: #cdcdcd; border: 1px solid #000;}
  #g_taxonomie_select li span { line-height: 18px; cursor: pointer; color: #000; }
  #g_taxonomie_select li span:hover {text-decoration: underline; background-color: #f1ffdd; display: block; z-index: 300; position: relative;}
  #g_taxonomie_select li:hover { background-color: #f1ffdd;}
  #g_taxonomie_select li.has_childs {background: #cdcdcd url(../images/arrow_right.gif) no-repeat center right;}
  #g_taxonomie_select li.has_childs:hover {background: #f1ffdd;}
  #g_taxonomie_select ul ul { position: absolute; display: none; top: -1px; left: 252px; margin: 0; padding: 0; box-shadow: 2px 1px 5px #000; -moz-box-shadow: 2px 1px 5px #000; -webkit-box-shadow: 2px 1px 5px #000;}
  #g_taxonomie_select ul li.hover > ul { display: block; }
  /** EOF AGI GOOGLE-ADWORDS-EXPORT www.andreas-guder.de */
/admin/includes/classes/categories.php

-----------------------
suchen:
-----------------------

Code: Alles auswählen

$sql_data_array = array ('sort_order' => $sort_order, 'categories_status' => $categories_status, 'products_sorting' => xtc_db_prepare_input($categories_data['products_sorting']), 'products_sorting2' => xtc_db_prepare_input($categories_data['products_sorting2']), 'categories_template' => xtc_db_prepare_input($categories_data['categories_template']), 'listing_template' => xtc_db_prepare_input($categories_data['listing_template']));
-----------------------
ersetzen durch:
-----------------------

Code: Alles auswählen

$sql_data_array = array ('sort_order' => $sort_order, 'categories_status' => $categories_status, 'products_sorting' => xtc_db_prepare_input($categories_data['products_sorting']), 'products_sorting2' => xtc_db_prepare_input($categories_data['products_sorting2']), 'categories_template' => xtc_db_prepare_input($categories_data['categories_template']), 'listing_template' => xtc_db_prepare_input($categories_data['listing_template']), 'google_category' => xtc_db_prepare_input($categories_data['google_category'])); // AGI GOOGLE-ADWORDS-EXPORT www.andreas-guder.de */
/admin/includes/classes/categories.php:
-----------------------
suchen:
-----------------------

Code: Alles auswählen

  //get the next ai-value from table products if no products_id is set
		if (!$products_id || $products_id == '') {
			$new_pid_query = xtc_db_query("SHOW TABLE STATUS LIKE '".TABLE_PRODUCTS."'");
			$new_pid_query_values = xtc_db_fetch_array($new_pid_query);
			$products_id = $new_pid_query_values['Auto_increment'];
		}
-----------------------
darunter einfügen:
-----------------------

Code: Alles auswählen

/** BOF AGI GOOGLE-ADWORDS-EXPORT www.andreas-guder.de */
    $agi_adwords_array = array(
      'google_category'             => xtc_db_prepare_input($products_data['google_category']),
      'agi_google_export'           => isset($_POST['agi_google_export']) ? 1 : 0,
      'agi_google_online_only'      => isset($_POST['agi_google_online_only']) ? 1 : 0,
      'agi_google_condition'        => xtc_db_prepare_input($products_data['agi_google_condition']),
      'agi_google_adwords_grouping' => xtc_db_prepare_input($products_data['agi_google_adwords_grouping']),
      'agi_google_adwords_labels'   => xtc_db_prepare_input($products_data['agi_google_adwords_labels']),
      'agi_google_adwords_redirect' => xtc_db_prepare_input($products_data['agi_google_adwords_redirect']),
      'agi_google_excluded_destination' => xtc_db_prepare_input($products_data['agi_google_excluded_destination']),
      'agi_google_expiration_date'  => xtc_db_prepare_input($products_data['agi_google_expiration_date']),
      'agi_google_identifier_exists'=> xtc_db_prepare_input($products_data['agi_google_identifier_exists']),
      'agi_google_products_brand'   => xtc_db_prepare_input($products_data['agi_google_products_brand']),
      'agi_google_energy_efficiency'=> xtc_db_prepare_input($products_data['agi_google_energy_efficiency']),
      'agi_google_multipack_amount' => xtc_db_prepare_input($products_data['agi_google_multipack_amount'])
    );
    $sql_data_array = array_merge($sql_data_array, $agi_adwords_array);
    /** EOF AGI GOOGLE-ADWORDS-EXPORT www.andreas-guder.de */
/admin/includes/modules/categories_view.php:
-----------------------
Zeilen suchen:
-----------------------

Code: Alles auswählen

  defined('_VALID_XTC') or die('Direct Access to this location is not allowed.'); 
-----------------------
darunter einfügen:
-----------------------

Code: Alles auswählen

  $show_agi_google_taxonomy = false; // AGI GOOGLE-ADWORDS-EXPORT www.andreas-guder.de */

/admin/includes/modules/categories_view.php (ca. Zeile 610):
-----------------------
Zeilen suchen:
-----------------------

Code: Alles auswählen

// multi_copy confirm ENDS
-----------------------
darunter einfügen:
-----------------------

Code: Alles auswählen

 /** BOF AGI GOOGLE-ADWORDS-EXPORT www.andreas-guder.de */
        // --------------------
        // multi_google_category confirm/select
        // --------------------
        if (xtc_not_null($_POST['multi_g_taxonomie'])) {  
            $agi_count = 0;
            $heading[]  = array('text' => '<b>' . TEXT_INFO_HEADING_GOOGLE_MULTI_CATEGORY . '</b>');
            $contents[] = array('text' => '<table width="100%" border="0">');
            if (is_array($_POST['multi_categories'])) {
                foreach ($_POST['multi_categories'] AS $multi_category) {
                    $category_query = xtc_db_query("select c.categories_id, cd.categories_name from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . $multi_category . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$_SESSION['languages_id'] . "'");
                    $category = xtc_db_fetch_array($category_query);
                    $contents[] = array('text' => '<tr><td style="border-bottom: 1px solid Black; margin-bottom: 10px;" class="infoBoxContent"><b>' . $category['categories_name'] . '</b></td></tr>');    
                    $product_categories_string = '';
                    $agi_count++;
                }
            } 
            if (is_array($_POST['multi_products'])) {
                foreach ($_POST['multi_products'] AS $multi_product) {
                    $contents[] = array('text' => '<tr><td style="border-bottom: 1px solid Black; margin-bottom: 10px;" class="infoBoxContent"><b>' . xtc_get_products_name($multi_product) . '</b></td></tr>');    
                    $product_categories_string = '';
                    $agi_count++;
                }
            }   
            $contents[] = array('text' => '</table>');
            if ($agi_count)
            {
              $show_agi_google_taxonomy = true;
              
              $contents[] = array('text' => '<p>' . TEXT_INFO_DESC_GOOGLE_MULTI_CATEGORY . '</p>');
              $contents[] = array('text' => xtc_draw_input_field('google_multi_category', '', 'readonly="readonly" style="width: 200px; background-color: #eee;"'));
              $contents[] = array('align' => 'center', 'text' => '<input class="button" type="submit" name="multi_g_taxonomie_confirm" value="' . BUTTON_GOOGLE_MULTI_CATEGORY . '"> <a class="button" href="' . xtc_href_link(FILENAME_CATEGORIES, xtc_get_all_get_params(array('cPath', 'action', 'pID', 'cID')) . 'cPath=' . $cPath . '&pID=' . $pInfo->products_id . '&cID=' . $cInfo->categories_id) . '">' . BUTTON_CANCEL . '</a>');            
            }
            else
            {
              $contents[] = array('align' => 'center', 'text' => '<a class="button" href="' . xtc_href_link(FILENAME_CATEGORIES, xtc_get_all_get_params(array('cPath', 'action', 'pID', 'cID')) . 'cPath=' . $cPath . '&pID=' . $pInfo->products_id . '&cID=' . $cInfo->categories_id) . '">' . BUTTON_CANCEL . '</a>');            
            }
            $contents[] = array('text' => '</form>'); 
        }
        /** EOF AGI GOOGLE-ADWORDS-EXPORT www.andreas-guder.de */  
/admin/includes/modules/categories_view.php:
-----------------------
Zeilen suchen:
ACHTUNG! 2 X
-----------------------

Code: Alles auswählen

$contents[] = array('align' => 'center', 'text' => '<input type="submit" class="button" name="multi_status_on" onclick="this.blur();" value="'. BUTTON_STATUS_ON . '">&nbsp;<input type="submit" class="button" onclick="this.blur();" name="multi_status_off" value="' . BUTTON_STATUS_OFF . '">');
-----------------------
jeweils darunter einfügen:
-----------------------

Code: Alles auswählen

 /** BOF AGI GOOGLE-ADWORDS-EXPORT www.andreas-guder.de */
  $contents[] = array('align' => 'center', 'text' => '<input type="submit" class="button" name="multi_g_taxonomie" onClick="this.blur();" value="'. BUTTON_GOOGLE_MULTI_CATEGORY . '">');
  /** EOF AGI GOOGLE-ADWORDS-EXPORT www.andreas-guder.de */
/admin/includes/modules/categories_view.php
-----------------------
am Ende einfügen:
-----------------------

Code: Alles auswählen

<!-- BOF AGI GOOGLE-ADWORDS-EXPORT www.andreas-guder.de //-->
<?php if ($show_agi_google_taxonomy) { ?>
      <span class="main">GOOGLE-Kategorie</span><br />
      <?php echo  xtc_draw_input_field('google_category', $pInfo->google_category, 'size="50" style="width: 96%" onChange="copy_google_category(this.value);"'); ?>
    </td>
  </tr>
  <tr>
    <td><div id="g_taxonomie_select"></div></td>
  </tr>
<script type="text/javascript" src="../export/google_taxonomie.json.js"></script>
<script type="text/javascript">
  if (g_taxonimie && document.getElementById('g_taxonomie_select') && document.getElementsByName('google_category'))
    create_agi_google_taxonomie();
  function create_agi_google_taxonomie()
  {
    var parent = document.getElementById('g_taxonomie_select');
    var ul = document.createElement('UL');
    ul.className = 'agi_taxonomie_select';
    parent.appendChild(ul);
    build_taxonomie_list_element(ul, '---', '');
    if (g_taxonimie.childs)
      build_agi_taxonomie_list(ul, g_taxonimie.childs);
  }
  function build_agi_taxonomie_list(parent, taxonomie_object)
  {
    for (var i in taxonomie_object)
    {
      var li = build_taxonomie_list_element(parent, i, taxonomie_object[i].string);
      li.className = 'agi_taxonomie_li'; // just for IE in Quirksmode
      if (taxonomie_object[i].childs)
      {
        var ul = document.createElement('UL');
        ul.className = 'agi_taxonomie_ul'; // just for IE in Quirksmode
        li.appendChild(ul);
        li.className = 'has_childs';
        li.onmouseover   = new Function('hover_taxonomie_list_element(this)');
        build_agi_taxonomie_list(ul, taxonomie_object[i].childs);
      }
    }
  }
  function build_taxonomie_list_element(parent, text, value)
  {
    var li = document.createElement('LI');
    parent.appendChild(li);
    var span = document.createElement('SPAN');
    span.className = 'agi_taxonomie_span'; // just for IE in Quirksmode
    li.appendChild(span);
    span.appendChild(document.createTextNode(decodeURIComponent(text)));
    span.onclick = new Function ("set_taxonomie_value('"+decodeURIComponent(value)+"')");
    return li;
  }
  function hover_taxonomie_list_element(me)
  {
    var myParent = me.parentNode;
    var lis = myParent.getElementsByTagName('LI');
    for (var i=0; i<lis.length; i++)
    {
      lis[i].className = lis[i].className.replace(new RegExp(" hover\\b"), "");
      lis[i].onmouseover = new Function('hover_taxonomie_list_element(this)');
    }
    me.className+=" hover";
    me.onmouseover = '';
  }
  function set_taxonomie_value(value)
  {
    document.getElementsByName('google_category')[0].value = value;
    document.getElementsByName('google_multi_category')[0].value = value;
  }
  function copy_google_category(value)
  {
    document.getElementsByName('google_multi_category')[0].value = value;
  }
</script>
  <tr>
    <td>
<?php } ?>
<!-- EOF AGI GOOGLE-ADWORDS-EXPORT www.andreas-guder.de //-->
/admin/includes/modules/new_category.php (ca. Zeile 169):
-----------------------
Zeilen suchen:
-----------------------

Code: Alles auswählen

  <tr>
    <td class="main"><?php echo TEXT_EDIT_SORT_ORDER; ?></td>
    <td class="main"><?php echo xtc_draw_input_field('sort_order', $cInfo->sort_order, 'size="2"'); ?></td>
  </tr>
-----------------------
darunter einfügen:
-----------------------

Code: Alles auswählen

<!-- BOF AGI GOOGLE-ADWORDS-EXPORT www.andreas-guder.de //-->
  <tr>
    <td><span class="main">GOOGLE-Kategorie</span></td>
    <td><span class="main"><?php echo  xtc_draw_input_field('google_category', $cInfo->google_category, 'size="50" style="width: 96%"'); ?></span></td>
  </tr>
  <tr>
    <td colspan="2"><div id="g_taxonomie_select"></div></td>
  </tr>
  <!-- EOF AGI GOOGLE-ADWORDS-EXPORT www.andreas-guder.de //-->
/admin/includes/modules/new_category.php:
-----------------------
Am Ende einfügen:
-----------------------

Code: Alles auswählen

<!-- BOF AGI GOOGLE-ADWORDS-EXPORT www.andreas-guder.de //-->
<script type="text/javascript" src="../export/google_taxonomie.json.js"></script>
<script type="text/javascript">
  if (g_taxonimie && document.getElementById('g_taxonomie_select') && document.getElementsByName('google_category'))
    create_agi_google_taxonomie();
  function create_agi_google_taxonomie()
  {
    var parent = document.getElementById('g_taxonomie_select');
    var ul = document.createElement('UL');
    ul.className = 'agi_taxonomie_select';
    parent.appendChild(ul);
    build_taxonomie_list_element(ul, '---', '');
    if (g_taxonimie.childs)
      build_agi_taxonomie_list(ul, g_taxonimie.childs);
  }
  function build_agi_taxonomie_list(parent, taxonomie_object)
  {
    for (var i in taxonomie_object)
    {
      var li = build_taxonomie_list_element(parent, i, taxonomie_object[i].string);
      li.className = 'agi_taxonomie_li'; // just for IE in Quirksmode
      if (taxonomie_object[i].childs)
      {
        var ul = document.createElement('UL');
        ul.className = 'agi_taxonomie_ul'; // just for IE in Quirksmode
        li.appendChild(ul);
        li.className = 'has_childs';
        li.onmouseover   = new Function('hover_taxonomie_list_element(this)');
        build_agi_taxonomie_list(ul, taxonomie_object[i].childs);
      }
    }
  }
  function build_taxonomie_list_element(parent, text, value)
  {
    var li = document.createElement('LI');
    parent.appendChild(li);
    var span = document.createElement('SPAN');
    span.className = 'agi_taxonomie_span'; // just for IE in Quirksmode
    li.appendChild(span);
    span.appendChild(document.createTextNode(decodeURIComponent(text)));
    span.onclick = new Function ("document.getElementsByName('google_category')[0].value='"+decodeURIComponent(value)+"'");
    return li;
  }
  function hover_taxonomie_list_element(me)
  {
    var myParent = me.parentNode;
    var lis = myParent.getElementsByTagName('LI');
    for (var i=0; i<lis.length; i++)
    {
      lis[i].className = lis[i].className.replace(new RegExp(" hover\\b"), "");
      lis[i].onmouseover = new Function('hover_taxonomie_list_element(this)');
    }
    me.className+=" hover";
    me.onmouseover = '';
  }
</script>
<!-- EOF AGI GOOGLE-ADWORDS-EXPORT www.andreas-guder.de //-->

/admin/includes/modules/new_product.php (ca. Zeile 211):

-----------------------
Zeilen suchen:
-----------------------

Code: Alles auswählen

 <br /><br />
  <?php for ($i = 0, $n = sizeof($languages); $i < $n; $i++) { ?>
-----------------------
DAVOR! einfügen:
-----------------------

Code: Alles auswählen

<!-- BOF AGI GOOGLE_EXPORT ADWORDS www.andreas-guder.de //-->
<table width="860" border="0">
  <tr>
    <td style="border: 1px solid; padding: 5px;">
<?php
 include (DIR_WS_MODULES.'agi_google_export.php');
 ?>
    </td>
  </tr>
</table>
<!-- EOF AGI GOOGLE_EXPORT ADWORDS www.andreas-guder.de //-->
/lang/german/admin/german.php:
-----------------------
am Ende einfügen:
-----------------------

Code: Alles auswählen

/** BOF AGI GOOGLE-ADWORDS-EXPORT www.andreas-guder.de */
define('BOX_GOOGLE_TAXONOMIE','Google Taxonomie');
define('BUTTON_GOOGLE_MULTI_CATEGORY', 'GOOGLE Kategorie setzen');
define('TEXT_INFO_HEADING_GOOGLE_MULTI_CATEGORY', 'GOOGLE Kategorie setzen');
define('TEXT_INFO_DESC_GOOGLE_MULTI_CATEGORY', 'Die Kategorieauswahl erfolgt am Ende der Seite');
/** EOF AGI GOOGLE-ADWORDS-EXPORT www.andreas-guder.de */
/lang/german/admin/categories.php:
-----------------------
am Ende einfügen:
-----------------------

Code: Alles auswählen

/** BOF AGI GOOGLE-ADWORDS-EXPORT www.andreas-guder.de */
define('AGI_GOOGLE_EXPORT_ALLOWED', 'Google-Export erlaubt?');
define('AGI_GOOGLE_ADWORDS_GROUPING', 'Adwords Gruppierung');
define('AGI_GOOGLE_ADWORDS_LABELS', 'Adwords Label');
define('AGI_GOOGLE_ADWORDS_REDIRECT', 'Adwords Weiterleitungs-URL');
define('AGI_GOOGLE_EXCLUDED_DESTINATION', 'ausgeschlossen von Zielanwendung');
define('AGI_GOOGLE_EXPIRATION_DATE', 'Ablaufdatum (JJJJ-MM-TT)');
define('AGI_GOOGLE_ONLINE_ONLY', 'Artikel nur online verf&uuml;gbar');
define('AGI_GOOGLE_CONDITION', 'Zustand');
define('AGI_GOOGLE_CATEGORY', 'Google-Kategorie');
define('TEXT_GOOGLE_CONDITION_REFURBISHED', 'erneuert');
define('TEXT_GOOGLE_CONDITION_USED', 'gebraucht');
define('TEXT_GOOGLE_CONDITION_NEW', 'neu');
define('AGI_GOOGLE_IDENTIFIER_EXISTS', 'Kennzeichnung existiert');
define('AGI_GOOGLE_PRODUCTS_BRAND', 'Marke (alternativ zum Hersteller)');
define('AGI_GOOGLE_ENERGY_EFFICIENCY', 'Energieeffizienzklasse');
define('AGI_GOOGLE_MULTIPACK_AMOUNT', 'Multipack (Anzahl Produkte)');
/** EOF AGI GOOGLE-ADWORDS-EXPORT */
Fertig! :) Solltet Ihr auch noch die englischen Änderungen benötigen, findet Ihr diese in folgendem Download-Paket: http://www.andreas-guder.de/sites/defau ... andard.zip
Bitte übernehmt dort jedoch nicht die Änderungen oder neuen Dateien. Nur die Änderungen hier sind für Webs gültig!

Eine Anleitung wie Ihr dieses Modul konfigurieren müsst, findet Ihr im oben genannten Download-Paket.

So, ich hoffe ich habe nichts übersehen. Ein kurzer Feedback würde mich freuen.

PS: An die Entwickler von Webs: Es wäre toll, wenn Ihr Euch dieses Modul mal ansehen könnt. Ich bin sicher, es wäre eine wertvolle Erweiterung welche bestimmt auch in einer zukünftigen Webs Version platz finden würde.

Liebe Grüsse
Kopernikus
basteldehs
Beiträge: 77
Registriert: So 20. Okt 2013, 06:29
Shop Version: 1.0.17
Wohnort: Chemnitz
Kontaktdaten:

Re: Modul Einbauanleitung: Google Merchant Center inkl Taxon

Beitrag von basteldehs »

Hi Kopernikus,

so habe dieses Modul auch mal eingebaut, hatte heute das Merchant Center gefunden und irgendwie hier draufgekommen, frag mich net wie :D


erstmal ein dickes fettes Dankeschön für die Ausführlichkeit deines Beitrages, hat auch alles funktioniert, muss morgen weiter machen mir rutschen die klissen zu ( augen )
stand: google holt noch keine Produkte. im Shop passt alles, muss morgen nur noch das mit den Kategorien machen und wir haben im august einen Beitrag im Forum stehen, hihihi


grüssle basteldehsi
Mein Online Shop http://www.bastel-dehs.de
basteldehs
Beiträge: 77
Registriert: So 20. Okt 2013, 06:29
Shop Version: 1.0.17
Wohnort: Chemnitz
Kontaktdaten:

Re: Modul Einbauanleitung: Google Merchant Center inkl Taxon

Beitrag von basteldehs »

Hallo halli,

was noch nicht klappt ist der aufruf der bastel-dehs.de/export/google_xml.php da kommt die Fehlermeldung Internal Server Error hängt irgendwie mit der htaccess date zusammen oder?

wer hat eine Tipp?

grüssle und Danke basteldehsi
Mein Online Shop http://www.bastel-dehs.de
Kopernikus
Beiträge: 390
Registriert: Fr 19. Okt 2012, 12:15

Re: Modul Einbauanleitung: Google Merchant Center inkl Taxon

Beitrag von Kopernikus »

Hallo basteldehs

Sorry, war lange nicht mehr hier. Klappt es in der Zwischenzeit? Übrigens, der Entwickler, Herr Guder, hat mir das Modul damals für Webs konfiguriert. Meine Beschreibung sollte aber eigentlich sämtliche Webs Anpassungen enthalten.

Die von mir hier publizierte Version berücksichtigt allerdings noch keine Attribute. Für diese Version musste man damals zusätzlich bezahlen. Neu bietet Herr Guder diese Version ebenfalls zum Download für xtc3 und modified an. Siehe http://www.andreas-guder.de

Das Problem: Bei Webs wurde viel geändert in den Attributen. Da klappt der 1:1 Einbau nicht mehr richtig. Da das Modul eines der Besten ist, welches es in diesem Bereich gibt, überlege ich mir, Herrn Guder nochmals für diese Arbeiten zu engagieren. Vielleicht wärst Du ja auch dabei?

LG
Kopernikus
basteldehs
Beiträge: 77
Registriert: So 20. Okt 2013, 06:29
Shop Version: 1.0.17
Wohnort: Chemnitz
Kontaktdaten:

Re: Modul Einbauanleitung: Google Merchant Center inkl Taxon

Beitrag von basteldehs »

Hallo Kopernikus,
die Anpassungen funktionieren ja auch, was momentan nicht funktioniert ist die google_xml.php siehe meinen Beitrag, der allgemeine Webs Exporter klappt ja auch super, es müssten nur noch ein paar Dinge da rein,
zB
<!-- brand Marke -->
<g:brand>
<![CDATA[ Hausmarke ]]>
</g:brand>

<!-- mpn Global Trade Item Number -->
<g:mpn>
<![CDATA[ 020040 ]]>
</g:mpn>

<!-- google_product_category -->
<g:google_product_category>
<![CDATA[ Kunst & Unterhaltung > Hobby & Kunst > Kunsthandwerk & Hobby > Modellbau ]]>
</g:google_product_category>

<!-- product_type -->
<g:product_type>
<![CDATA[ Modellbau ]]>
</g:product_type>

<!-- availability -->
<g:availability>
<![CDATA[ in stock ]]>
</g:availability>

<!-- shipping -->
<g:shipping>
<g:country>
<![CDATA[ DE ]]>
</g:country>

<g:service>
<![CDATA[ Standard ]]>
</g:service>

<g:price>
<![CDATA[ 2.90 € ]]>
</g:price>
</g:shipping>

<!-- shipping_weight Gewicht -->
<g:shipping_weight>
<![CDATA[ 0.005kg ]]>
</g:shipping_weight>

<!-- online_only -->
<g:online_only>
<![CDATA[ n ]]>
</g:online_only>

dann kann man den auch nehmen, dies kann man ja mal mit Yogi besprechen, was ich auch mal mache und so wie ich aus dem Buschfunk gehört habe, wird an den Attributen Verbesserungen vorgenommen.

grüssle basteldehsi
Mein Online Shop http://www.bastel-dehs.de
Kopernikus
Beiträge: 390
Registriert: Fr 19. Okt 2012, 12:15

Re: Modul Einbauanleitung: Google Merchant Center inkl Taxon

Beitrag von Kopernikus »

Ich kann Dir da im Detail auch nicht helfen. Ich habe den Einbau und die ganzen Anpassungen durch Herrn Guder machen lassen. Es ist aber in der Tat so. Dieses Modul ist wohl das Beste in diesem Bereich welche es gibt. Da Herr Guder es nun als Open Source anbietet, könnte man mit Yogi mal besprechen, ob eine Integration möglich wäre. Ich würde mich auf jeden Fall sehr freuen. :D
Kopernikus
Beiträge: 390
Registriert: Fr 19. Okt 2012, 12:15

Re: Modul Einbauanleitung: Google Merchant Center inkl Taxon

Beitrag von Kopernikus »

Hallo basteldehs

Ich hab Dir mal ein ZIP File aller benötigten Dateien erstellt. Möglicherweise habe ich damals ja etwas in der Anleitung vergessen. Schau mal ob es mit diesen Dateien funktioniert. Sollte alles richtig installiert sein, findest Du unter Module/Web Shop Module den neuen Eintrag mit dem Namen "XML-Datenfeed für Google-Merchant-Center"

Ich hoffe es klappt :)

http://www.file-upload.net/download-959 ... l.zip.html
basteldehs
Beiträge: 77
Registriert: So 20. Okt 2013, 06:29
Shop Version: 1.0.17
Wohnort: Chemnitz
Kontaktdaten:

Re: Modul Einbauanleitung: Google Merchant Center inkl Taxon

Beitrag von basteldehs »

Hi Kopernikus,

so erstmal danke fein für die Zip-datei, die habsch mal rundergeladen und der Eintrag "XML-Datenfeed für Google-Merchant-Center" war schon da, habe es nur wieder deaktiviert und was kommt hier rein Hilfsprogramme -> Google-Taxonomie
und wie schon gesagt, funktioniert die /export/google_xml.php datei nicht (Internal Server Error) ansonsten kann man da schon was eintragen bei Produkteingabe

und das Modul ist doch eigentlich nur von nutzen wenn man bei google die Adwords hat, also bezahlklicks, oder?

grüssle und danke bastel dehsi
Mein Online Shop http://www.bastel-dehs.de
Antworten