Neuigkeiten
  • Die modified eCommerce Shopsoftware ist kostenlos, aber nicht umsonst.
    Spenden
  • Damit wir die modified eCommerce Shopsoftware auch zukünftig kostenlos anbieten können:
    Spenden
  • Thema: XML Export ParentID Kategoriename ausgeben

    karabey

    • Schreiberling
    • Beiträge: 320
    • Geschlecht:
    XML Export ParentID Kategoriename ausgeben
    am: 16. September 2013, 01:36:13
    Hallo,

    Ich habe den RSS Modul ein wenig umgeändert um meine Produkte als XML auszugeben. Funktioniert einwandfrei nur ich möchte bei jeden Produkt noch die Kategorie und Parent Kategorie einfügen.

    Würde mich über eine unterstützung freuen

    Code: PHP  [Auswählen]
    <?php

    header('Content-Type: application/xml; charset="ISO-8859-1"',true);
    /*
    * owl-concept.com, I. Jonas - v 0.1 - 2013 - for modified eCommerce Shopsoftware
    * Rewritten from (( Wir dulden keine kommerziellen Werbelinks - Bitte Forenregeln beachten! )), Daniel Siekiera - 2010
    * Released under the GNU General Public License
    * This software is provided 'as-is', without any express or implied
    * warranty. In no event will the authors be held liable for any
    * damages arising from the use of this software.
    * The script will generate 2 files called
    * sitemap2.xml and sitemap3.xml.gz in the root directory,
    */

    //$start = microtime(true);

    # some settings
    $output                 = "";

    $imageLarge             = "popup_images/";
    $imageThumb             = "thumbnail_images/";
    $imageMain              = "info_images/";
    $imagesource    = 'http://'.$_SERVER['SERVER_NAME'].'/'."images/product_images/";
    $SiteLink               = 'http://www.'.$_SERVER['SERVER_NAME'].'/';
    $root                   = $_SERVER['DOCUMENT_ROOT']."/";
    $usage_hours    = 0.0001; # for testing purposes only: 0.002777777777777777777778 h = 10 sec.
    $xml_file               = "products.xml";
    $gz_xml_file    = "products.xml.gz";
    $with_tax = false; //TRUE => inkl. MwSt, FALSE => exkl. MwSt

    # generate files if sitemap2.xml does not exist or is outdated
    if(!file_exists($root.$xml_file) || (file_exists($root.$xml_file) && time()-filemtime($root.$xml_file)>$usage_hours*3600)) {

            # switch on output buffering
            ob_start();

            # switch off gzip compression & call application_top.php
            define('GZIP_COMPRESSION' , false);
            require_once ($root.'includes/application_top.php');
           
    /*      error_reporting(-1);
            ini_set("display_errors", TRUE); */

           
            function iso8601_date($timestamp) {
                    if (PHP_VERSION < 5) {
                            $tzd = date('O',$timestamp);
                            $tzd = substr(chunk_split($tzd, 3, ':'),0,6);
                            return date('Y-m-d\TH:i:s', $timestamp) . $tzd;
                    } else {
                            return date('c', $timestamp);
                    }
            }

            function xtc_get_languages() {
            $languages_array = array();
            $languages_query = xtc_db_query("SELECT languages_id, code, sort_order FROM languages ORDER BY sort_order");
                    while ($languages = xtc_db_fetch_array($languages_query))
                            $languages_array[] = array ('id' => $languages['languages_id'], 'code' => $languages['code']);
                    return $languages_array;
            }
            $all_languages = xtc_get_languages();

            function rv_get_path($cat_id, $code) {
                    global $cat_array;
                    $my_cat_array = array($cat_id);
                    while($cat_array[$cat_id][$code]['parent_id'] != 0) {
                            $my_cat_array[] = $cat_array[$cat_id][$code]['parent_id'];
                            $cat_id = $cat_array[$cat_id][$code]['parent_id'];
                    }
                    return xtc_category_link($my_cat_array[0]);
            }
           
            echo '<?xml version="1.0" encoding="ISO-8859-1"?>' . "\n";
            echo '<products>' . "\n";

            $i = 0; $k = count($all_languages);
            while($i < $k) {

                    //$lang_param = ($all_languages[$i]['code'] != DEFAULT_LANGUAGE) ? '&language='.$all_languages[$i]['code'] : '';
                    //$lang_param = ($k != 1) ? '&language='.$all_languages[$i]['code'] : ''; # this param is essentially needed for correct link building !!!
                   
                    ##### BOF - PRODUCTS #####
                    $product_query = xtc_db_query("
                                                                            select
                                                                                    p.products_id,
                                                                                    p.products_ean,
                                                                                    pd.products_name,
                                                                                    pd.products_short_description,
                                                                                    pd.products_description,
                                                                                    p.products_price,
                                                                                    p.products_image,
                                                                                    p.products_model,
                                                                                    p.group_permission_1,
                                                                                    p.products_date_added,
                                                                                    p.products_last_modified,
                                                                                    p.products_tax_class_id,
                                                                                    s.specials_new_products_price
                                                                            from
                                                                                    (products p INNER JOIN products_description pd ON p.products_id = pd.products_id) LEFT JOIN specials s ON p.products_id = s.products_id
                                                                            where p.products_status = '1'
                                                                            and pd.language_id = "
    .$_SESSION['languages_id']."
                                                    "
    .$group_check."
                                                    "
    .$days."
                                                                            order by
                                                                            p.products_date_added DESC"
    );
                                                                           
                   
                           
                            if(xtc_db_num_rows($product_query)) {
                                                                                           
                            while($product = xtc_db_fetch_array($product_query)) {
                                   
                                    $netPrice = $product['products_price'] * 1.2;
                                    $price = number_format($netPrice,2,'.','').' EUR' ;
                                   
                                    $tax_rate = $xtPrice->TAX[$listing['products_tax_class_id']];
                                    if ($with_tax) {
                                            $tax_info = sprintf(TAX_INFO_INCL, $tax_rate.' %');
                                    } else {
                                            $tax_info = sprintf(TAX_INFO_ADD, $tax_rate.' %');
                                    }
                                   
                                                           
                                    $link = htmlspecialchars(utf8_encode(xtc_href_link(FILENAME_PRODUCT_INFO, xtc_product_link($product['products_id'].$lang_param), 'NONSSL', false, SEARCH_ENGINE_FRIENDLY_URLS)));
                                   
                                    $date = ($product['products_last_modified'] != NULL) ? $product['products_last_modified'] : $product['products_date_added'];
                                    echo "\t".'<product id="'.$product['products_id'].'">' . "\n";
                                    echo "\t\t".'<name><![CDATA['. htmlentities($product['products_name']).']]></name>' . "\n";
                                    echo "\t\t".'<sku>'.$product['products_model'].'</sku>' . "\n";
                                    echo "\t\t".'<url>' . htmlspecialchars($link) . '</url>' . "\n";
                                    echo "\t\t".'<netPrice>'. $price .'</netPrice>' . "\n";
                                    echo "\t\t".'<description><![CDATA['. $product['products_description'].']]></description>' . "\n";
                                    echo "\t\t".'<image>'. "\n";
                                    echo "\t\t\t".'<main>'.$imagesource.$imageMain. $product['products_image'].'</main>' . "\n";
                                    echo "\t\t\t".'<thumb>'.$imagesource.$imageThumb. $product['products_image'].'</thumb>' . "\n";
                                    echo "\t\t\t".'<large>'.$imagesource.$imageLarge. $product['products_image'].'</large>' . "\n";
                                    echo "\t\t".'</image>'. "\n";
                                   
                                   
                                    echo "\t\t".'<datePublished>'.$product['products_date_added'].'</datePublished>' . "\n";
                                    echo "\t\t".'<lastmod>'.$product['products_last_modified'].'</lastmod>' . "\n";
                                    echo "\t".'</product>' . "\n";
                            }
                    }
                    ##### EOF - PRODUCTS #####     

                    ##### BOF - CATEGORIES #####
                   
                    $cat_result = xtc_db_query("SELECT      c.categories_id,
                                                                                            c.parent_id,
                                                                                            UNIX_TIMESTAMP(c.date_added) AS date_added,
                                                                                            UNIX_TIMESTAMP(c.last_modified) AS last_modified,
                                                                                            cd.language_id,
                                                                                            cd.categories_name
                                                                            FROM
                                                                                            "
    .TABLE_CATEGORIES."                            c,
                                                                                            "
    .TABLE_CATEGORIES_DESCRIPTION."        cd
                                                                            WHERE
                                                                                            c.categories_status = '1'
                                                                                            AND c.categories_id = cd.categories_id
                                                                                            AND cd.language_id = '"
    .$all_languages[$i]['id']."'
                                                                                            ORDER by cd.categories_id"
    );
                   

    if (xtc_db_num_rows($cat_result) > 0) {
            while($cat_data = xtc_db_fetch_array($cat_result)) {
                    $cat_array[$cat_data['categories_id']][$cat_data['code']] = $cat_data;
            }
    }
    reset($cat_array);

    foreach($cat_array as $lang_array) {
            foreach($lang_array as $cat_id => $cat_data) {
                   
                   
                    echo "\t\t".'<category id="'.$cat_data['categories_id'].'">'.$cat_data['categories_name'].'</category>' . "\n";
                    echo "\t\t".'<parentCategory id="'.$cat_data['parent_id'].'">'.$cat_data['categories_name'].'</parentCategory>' . "\n";
            }
    }
                   
                    ##### EOF - CATEGORIES #####
                   
                    $i++;
            }
            echo ('</products>' . "\n");
           
            # store & clean output buffer
            $output = ob_get_clean();
            $output = str_replace(array('<br />', '<br>', '<br/>'), '', $output);

            # store or overwrite file 'sitemap2.xml'
            $fh = fopen($root.$xml_file,'w');
            fputs($fh, $output);
            fclose($fh);
           
            # unlink .gz-file first
            if (file_exists($gz_xml_file)) unlink($gz_xml_file);

            # create .gz-file of 'sitemap2.xml'
            file_put_contents("compress.zlib://$gz_xml_file", file_get_contents($xml_file));  # (slightly faster execution)
            ### OR (slower execution) ###
            //$fp = gzopen ($gz_xml_file, 'w9');
            //gzwrite ($fp, file_get_contents($xml_file));
            //gzclose($fp);

    # else use sitemap2.xml if exists
    } else {
            # load existing, previously generated sitemap
            $output = file_get_contents($root.$xml_file);
    }

    # output content
    //$duration = microtime(true) - $start;
    //echo "This script took '.$duration.' seconds.";
    echo $output;
    ?>


    Linkback: https://www.modified-shop.org/forum/index.php?topic=27692.0
    8 Antworten
    4446 Aufrufe
    21. Juni 2013, 07:58:16 von dops_ab
    4 Antworten
    4328 Aufrufe
    20. Juli 2011, 21:49:03 von web28
    2 Antworten
    2389 Aufrufe
    16. August 2012, 14:10:42 von Bake
    5 Antworten
    3291 Aufrufe
    03. Oktober 2014, 18:00:57 von StefanWaltenberger
               
    anything