[ gelöst ] WaWi Import - Zugriff auf Attribute

Hallo Heiner, Vielen Dank für Deine Antwort. Über den Warenwirtschaftsexport funktinoiert das leider nicht, das ist fest in der Software verdrahtet dass zusätzliche Felder immer als Attribute ausgespuckt werden. Ich kann mich nur entscheiden welche id das Attribut bekommt (1-20). Der php Quelltext für den Import sieht so aus - könnte sein dass du den schon mal gesehen hast :slight_smile: [code]<?php error_reporting(“E_ALL”);
ini_set(“display_errors”,1);
ini_set(“display_startup_errors”, 1);
ini_set(“max_execution_time”, 0);
/**

  • Shopware API Beispiel: Artikel im XML - Format importieren
  • @author Heiner Lohaus hl@shopware2.de * @package Shopware 2.08.01 * @subpackage API */ /* Klassen laden, Aliase erstellen und Einstellungen vornehmen */ require_once(realpath(dirname(__FILE__)).’/…/api/api.php’); api = new sAPI(); if (_REQUEST[“sAPI”]!=api-\>sSystem-\>sCONFIG["sAPI"]&&count(_SERVER[‘argv’]) < 1) { #exit; } $import =& $api->import->shopware; $xml =& $api->convert->xml; $mapping =& $api->convert->mapping; $import->sDeleteAllCategories(); $import->sDeleteAllArticles(); $data_path = current(glob($api->sPath."/files/import/articles/*.xml")); if(empty($data_path)) { #print "-- ERROR – Keine XML Datei gefunden! no Data path: $data_path
    "; echo " – ERROR – Keine XML Datei gefunden! no Data path: $data_path
    "; die(); } $xml->sSettings[‘encoding’] = “ISO-8859-1”; $data = $api->convert->xml->decode($data_path); #if(!@unlink($data_path)) # exit; if(isset($data[“shopware”][“categories”])) { $xml->fix_array($data[“shopware”][“categories”],“category”); $categories = $data[“shopware”][“categories”]; $categorymask = array ( “parent”=>“parentID”, “description”, “id”, “description”, “position”, “alias”, “metakeywords”, “metadescription”, “cmsheadline”, “cmstext”, “template”, “aliassql” ); $categories = $mapping->convert_array ($categorymask, $categories); foreach ($categories as $category) { $import->sCategory($category); } #$import->sDeleteOtherCategories($categories); } if(isset($data[“shopware”][“articles”])) { $xml->fix_array($data[“shopware”][“articles”],“article”); $articles =& $data[“shopware”][“articles”]; echo "

Importvorgang gestartet!

"; echo "Es werden: “.count($articles).” Artikel importiert!
"; echo "Bitte haben Sie einen Moment Geduld.
Das Importieren der Artikel kann mehrere Minuten in Anspruch nehmen.

“; $articlemask = array ( “ordernumber”, “articledetailsID” => array(“isset”), “articleID” => array(“isset”), “name” => array(“isset”), “description” => array(“isset”), “description_long” => array(“isset”), “shippingtime” => array(“isset”), “shippingfree” => array(“isset”), “laststock” => array(“isset”), “releasedate” => array(“isset”), “topseller” => array(“isset”), “free” => array(“isset”), “keywords” => array(“isset”), “minpurchase” => array(“isset”), “packunit” => array(“isset”), “purchasesteps” => array(“isset”), “maxpurchase” => array(“isset”), “purchaseunit” => array(“isset”), “status_description” => array(“isset”), “referenceunit” => array(“isset”), “suppliernumber” => array(“isset”), “additionaltext”, “active” => array(“isset”), “instock” => array(“isset”), “stockmin” => array(“isset”), “esd” => array(“isset”), “weight” => array(“isset”), “position” => array(“isset”), “taxID” => array(“isset”), “supplierID” => array(“isset”), “unitID” => array(“isset”), “tax” => array(“isset”), “supplier” => array(“isset”), “added” => array(“isset”), “mainnumber” => array(“empty”), “attr” => array( “isset”, “field” => “attributes” ), “downloads” => array(“isset”), “informations” => array(“isset”), “images” => array(“isset”), “prices” => array(“isset”), “relationships” => array(“isset”), “categories” => array(“isset”), “configurator” => array(“isset”) ); $articlemask = $mapping->prepare_mask ($articlemask); $insert_articles = array(); $i=0; foreach ($articles as $article) { $testarray = $article; $i++; echo "
“.$i.”. Artikel '”.($article[‘name’])."’ mit der Artikelnummer ‘".($article[‘ordernumber’])."’ erfolgreich importiert!
"; $xml->fix_array($article[‘attributes’],“attribute”); $xml->fix_array($article[‘downloads’],“download”); $xml->fix_array($article[‘images’],“image”); $xml->fix_array($article[‘categories’],“category”); $xml->fix_array($article[‘prices’],“price”); $xml->fix_array($article[‘crossselling’],“article”); $xml->attr_as_key($article[‘attributes’],“id”); $article = $mapping->convert_line($articlemask, $article, true); if(!$article_insert = $import->sArticle($article)) continue; $article = array_merge($article, $article_insert); if(empty($article[“mainnumber”])) { if(isset($article[“crossselling”])) $import->sArticleCrossSelling (array(“articleID”=>$article[“articleID”]), $article[“crossselling”]); if(isset($article[“images”])) { $inserts = array(); $import->sDeleteOtherArticleImages ($article[“articleID”], $inserts); foreach ($article[“images”] as $image) { //echo "Anzahl importierter Artikel: “.$i.”
"; //echo "

".print\_r($image)."

“; $image[“link”] = $api->sPath.”/files/import/images/".basename($image[“link”]); $image[“articleID”] = $article[“articleID”]; $image[“ordernumber”] = $article[“ordernumber”]; //$image[“position”] = $article[“position”]; //$insert = $import->sArticleImage($image); //echo "

".print\_r($insert)."

“; if($insert = $import->sArticleImage($image)) { $inserts = $insert; } else { echo " » WARNUNG: es konnte kein Artikelbild für den Artikel importiert werden. Grund: Bild-Datei fehlt auf dem Server”; } //@unlink($image[“link”]); } } if(isset($article[“downloads”])) { $download_path = $api->sPath.$api->sSystem->sCONFIG[‘sARTICLEFILES’]."/". $sql = “SELECT filename FROM s_articles_downloads WHERE articleID={$article[“articleID”]}”; $downloads = $api->sDB->GetCol($sql); foreach ($downloads as $download) { if(file_exists($download_path.$download)) @unlink($download_path.$download); } $sql = “DELETE FROM s_articles_downloads WHERE articleID={$article[“articleID”]}”; $api->sDB->Execute($sql); $inserts = array(); foreach ($article[“downloads”] as $download) { $download[“link”] = $api->sPath."/files/import/pdf/".basename($download[“filename”]); $download[“filename”] = basename($download[“link”]); $download[“new_link”] = $api->sPath.$api->sSystem->sCONFIG[‘sARTICLEFILES’]."/".$download[“filename”] ; if(file_exists($download[“link”])){ @unlink($download[“new_link”]); if(!copy($download[“link”],$download[“new_link”])) continue; //@unlink($download[“link”]); } else { continue; } $download[“size”] = filesize($download[“new_link”]); $download[“description”] = $api->sDB->qstr($download[“description”]); $download[“filename”] = $api->sDB->qstr($download[“filename”]); $sql = " INSERT INTO s_articles_downloads (articleID, description, filename, size) VALUES ({$article[“articleID”]}, {$download[“description”]}, {$download[“filename”]}, {$download[“size”]}); “; $api->sDB->Execute($sql); $insert = $api->sDB->Insert_ID(); } } if(isset($article[“categories”])) $import->sArticleCategories (array(“articleID”=>$article[“articleID”]), $article[“categories”]); } if(isset($article[“prices”])) { foreach ($article[“prices”] as $price) { $import->sArticlePrice(array( “articledetailsID”=>$article[“articledetailsID”], “price”=>$price[“net_price”], “pricegroup”=>$price[“pricegroup”], “net_pseudoprice”=>$price[“net_pseudoprice”], “net_pseudoprice”=>$price[“pseudoprice”], “pseudoprice”=>$price[“net_pseudoprice”], “from”=>$price[“from”] )); } } $insert_articles = $article[“articledetailsID”]; if(isset($article[‘configurator’])) { $import->sArticleConfigurator(array( ‘articleID’ => (int) $article[‘articleID’], ‘values’ => $article[‘configurator’][‘values’][‘value’], ‘type’ => $article[‘configurator’][‘type’], ‘tax’ => $article[‘tax’], )); } } //$import->sDeleteOtherArticles($insert_articles); //echo "
deleteotherarticles”; } echo "
Es wurden “.$i.” Artikel importiert!

"; //$import->sDeleteEmptyCategories(); $import->sDeleteCache(); echo “Importvorgang abgeschlossen!”; ?> [/code]