[ gelöst ] WaWi Import - Zugriff auf Attribute

Hallo, Ich importiere über eine XML-Schnittstelle Artikel aus einem Warenwirtschaftssystem in Shopware. Nun habe ich ein zusätzliches Attribut, welches ich gerne auf die Kurzbeschreibung also “description” mappen würde. Das Mapping sieht im Moment so aus: $articlemask = array ( "ordernumber", "articledetailsID" =\> array("isset"), "articleID" =\> array("isset"), "name" =\> array("isset"), ... XML Sieht so aus: <name>Mein Artikel</name><ordernumber>00000001</ordernumber><releasedate>2011-08-24</releasedate><active>1</active><supplierid>1</supplierid>.....<categories> <category>14</category> </categories>....<attributes> <attribute id="20">Knallrotes Gummiboot</attribute> </attributes>.... .. Und nun zu meine Frage: Wie könnte ich das Mapping umbauen um immer direkt auf den Inhalt von "attribute id=“20” zuzugreifen, damit dann beim import als description tatsächlich “Knallrotes Gummiboot” eingetragen wird? Ich hoffe das ist nicht allzu kryptisch was ich da formuliert habe und freue mich schon auf Antworten. Vielen Dank!

Ist die Fragestellung zu komplex oder zu trivial? lg

Hi, über das Shopware-Mapping ist sowas leider nicht möglich. Das müsstest du schon selber über PHP machen. Wie sieht denn hier z.Z. dein Quelltext dazu aus? Bisher hast du nur das Mapping gepostet. Und wenn du schon die Artikel aus der Wawi im Shopware-XML-Format exportieren kannst, warum kannst nicht dort auch diese Anpassung vornehmen? Heiner

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]

Ok, du must dazu nur nach dieser Zeile: $article = $mapping-\>convert\_line($articlemask, $article, true); diese Zeile einbauen: $article['description'] = $article['attr'][20]; unset($article['attr'][20]); Danach sollte deine Artikel-Kurzbeschreibung aus dem Attributesfeld 20 kommen. :sunglasses: Heiner

1 „Gefällt mir“

WOW. Damit hätte ich jetzt nicht gerechnet - eine top funktionierende fix fertige Lösung. Vielen Dank!:thumbup:

WOW. Damit hätte ich jetzt nicht gerechnet - eine top funktionierende fix fertige Lösung. Vielen Dank!:thumbup:

Moin! Ganz andere Frage: Darf man erfahren, welche WaWi Du da angebunden hast? AS

Handelt sich um eine Anbindung von Sage Office Line.

Hallo zusammen, auch von der soluto GmbH gibt es seit kurzem einen Shopware-Connector. Er ist Teil der bewährten Multi-Shop-Schnittstelle. Damit haben wir allein in den vergangenen 2 Wochen 4 Shopware-Shops angebunden. Nach 2,5 Stunden lief alles komplett inkl. Schulung. Ideal war, dass wir alle Daten mit einem Mausklick aus bestehenden Shops übernehmen und in den neuen Shopware hochladen könnten. Bei einem Projekt haben wir mit Multi-Shop-Schnittstelle auch noch die iPads des Außendienstes an die Office Line angebunden. Alles unter einer Oberfläche in der Office Line. Für weitere Details: http://shopware.multi-shop-schnittstelle.de/ Für eine Live-Demo und weitere Informationen einfach direkt an mich wenden: soluto GmbH Sternenstraße 13 77694 Kehl/ Rhein Tel: +49 7851 7089508 Fax: +49 7851 7089509 mschauer@solutobusiness.de Gruß Marco Schauer