WCM Forum

WCM Forum (http://www.wcm.at/forum/index.php)
-   Programmierung (http://www.wcm.at/forum/forumdisplay.php?f=17)
-   -   Auslesung von Lagerstand (http://www.wcm.at/forum/showthread.php?t=133402)

str1ker 05.05.2004 13:42

Auslesung von Lagerstand
 
Also ich steht einfach derzeit an...

Habe ein Script erweitert, das mir aus meiner Tabelle bestimmte Tabellen in eine CSV-Datei exportiert. Das ganze dient für osCommerce und soll mir helfen das ich endlich Lagerstände beim Geizhals anzeigen kann...

PHP-Code:

<?php

$referrer 
'none';  // enter youre referer here!

$export_file 'exportfile.csv';  // enter youre referer here!

require('includes/application_top.php');

function 
description_decoder($myHTML) {
  
$translation_table get_html_translation_table (HTML_ENTITIES,ENT_QUOTES);
  
$translation_table[chr(38)] = '&';
  return 
preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&amp;" strtr($myHTML$translation_table));
  }

$sql_query tep_db_query("
SELECT
        p.products_id,
        p.products_price,
        d.products_name,
        p.products_tax_class_id,
        concat(parentcd.categories_name , ' ' , cd.categories_name) as categorie_longname,
           p.products_availability_id,
        pan.products_availability_name
FROM
        products p,
        products_description d,
        products_to_categories p2c,
        categories_description cd,
        categories_description parentcd,
        categories c,
        products_availability pan
WHERE
        p.products_id = d.products_id
        AND
        p2c.products_id = p.products_id
        AND
        p2c.categories_id = cd.categories_id
        AND
        parentcd.categories_id = c.parent_id
        AND
        c.categories_id = p2c.categories_id
ORDER BY p.products_id
"
);

if (isset(
$referrer) != TRUE)  $referrer="none";

$export '"offerID";"name";"prices";"merchantCategory";"deepLink";"products_availability_id";"products_availability_name"'"\n" ;

while(
$sql_current_result tep_db_fetch_array($sql_query)) {

   
$export .=  '"' $sql_current_result['products_id'] .
        
'";"' description_decoder($sql_current_result['products_name']) .
        
'";"' $currencies->display_price($sql_current_result['products_price'], tep_get_tax_rate($sql_current_result['products_tax_class_id'])) .
        
'";"' description_decoder($sql_current_result['categorie_longname']) .
        
'";"' tep_href_link(FILENAME_PRODUCT_INFO'products_id=' $sql_current_result['products_id'] . '&ad=' $referrer) .
        
'";"' $sql_current_result['products_availability_id'] .
        
'";"' $sql_current_result['products_availability_name'] .
        
'"'"\n";
  }

$fp fopen(DIR_FS_CATALOG $export_file 'w');
  
fputs($fp$export);
  
fclose($fp);

require(
DIR_WS_INCLUDES 'application_bottom.php');
?>

Wenn ich das Script starte liest es die Daten aus der Datenbank aus und schreibt dieses am Server in eine CSV-Datei. Wenn ich die dann öffne sehe ich jedes Produkt das aus der Datenbank ausgelesen wurde zweimal. Einerseits mit Lagernd und Einmal mit Nicht Lagernd!

Ich hoffe es kann mir jemand helfen...


Alle Zeitangaben in WEZ +2. Es ist jetzt 19:30 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© 2009 FSL Verlag