# \[ gelöst \] WaWi Import - Zugriff auf Attribute

**URL:** <https://forum.shopware.com/t/gelost-wawi-import-zugriff-auf-attribute/4045>\
**Category:** Shopware 3.5\
**Tags:** programming\
**Created:** [25. August 2011 um 11:44 UTC](https://forum.shopware.com/t/gelost-wawi-import-zugriff-auf-attribute/4045 "2011-08-25T11:44:21Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![klexl](https://avatars.discourse-cdn.com/v4/letter/k/dc4da7/32.png) [@klexl](https://forum.shopware.com/u/klexl)\
**Post date:** [25. August 2011 um 11:44 UTC](https://forum.shopware.com/t/gelost-wawi-import-zugriff-auf-attribute/4045/1 "2011-08-25T11:44:21Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![klexl](https://avatars.discourse-cdn.com/v4/letter/k/dc4da7/32.png) [@klexl](https://forum.shopware.com/u/klexl)\
**Post date:** [29. August 2011 um 09:48 UTC](https://forum.shopware.com/t/gelost-wawi-import-zugriff-auf-attribute/4045/2 "2011-08-29T09:48:44Z")

</div>

Ist die Fragestellung zu komplex oder zu trivial? lg

---

<div class="post-metadata">

**Author:** ![Heiner\_Lohaus](https://avatars.discourse-cdn.com/v4/letter/h/b5a626/32.png) [@Heiner\_Lohaus](https://forum.shopware.com/u/Heiner_Lohaus)\
**Post date:** [29. August 2011 um 11:22 UTC](https://forum.shopware.com/t/gelost-wawi-import-zugriff-auf-attribute/4045/3 "2011-08-29T11:22:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![klexl](https://avatars.discourse-cdn.com/v4/letter/k/dc4da7/32.png) [@klexl](https://forum.shopware.com/u/klexl)\
**Post date:** [30. August 2011 um 07:32 UTC](https://forum.shopware.com/t/gelost-wawi-import-zugriff-auf-attribute/4045/4 "2011-08-30T07:32:48Z")

</div>

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 🙂 [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](mailto: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]

---

<div class="post-metadata">

**Author:** ![Heiner\_Lohaus](https://avatars.discourse-cdn.com/v4/letter/h/b5a626/32.png) [@Heiner\_Lohaus](https://forum.shopware.com/u/Heiner_Lohaus)\
**Post date:** [30. August 2011 um 08:27 UTC](https://forum.shopware.com/t/gelost-wawi-import-zugriff-auf-attribute/4045/5 "2011-08-30T08:27:43Z")

</div>

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. 🕶 Heiner

---

<div class="post-metadata">

**Author:** ![klexl](https://avatars.discourse-cdn.com/v4/letter/k/dc4da7/32.png) [@klexl](https://forum.shopware.com/u/klexl)\
**Post date:** [30. August 2011 um 09:11 UTC](https://forum.shopware.com/t/gelost-wawi-import-zugriff-auf-attribute/4045/6 "2011-08-30T09:11:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![klexl](https://avatars.discourse-cdn.com/v4/letter/k/dc4da7/32.png) [@klexl](https://forum.shopware.com/u/klexl)\
**Post date:** [30. August 2011 um 09:12 UTC](https://forum.shopware.com/t/gelost-wawi-import-zugriff-auf-attribute/4045/7 "2011-08-30T09:12:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Alpine\_Swift](https://avatars.discourse-cdn.com/v4/letter/a/8dc957/32.png) [@Alpine\_Swift](https://forum.shopware.com/u/Alpine_Swift)\
**Post date:** [31. August 2011 um 09:09 UTC](https://forum.shopware.com/t/gelost-wawi-import-zugriff-auf-attribute/4045/8 "2011-08-31T09:09:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![klexl](https://avatars.discourse-cdn.com/v4/letter/k/dc4da7/32.png) [@klexl](https://forum.shopware.com/u/klexl)\
**Post date:** [28. Dezember 2011 um 09:55 UTC](https://forum.shopware.com/t/gelost-wawi-import-zugriff-auf-attribute/4045/9 "2011-12-28T09:55:12Z")

</div>

Handelt sich um eine Anbindung von Sage Office Line.

---

<div class="post-metadata">

**Author:** ![mschauer](https://avatars.discourse-cdn.com/v4/letter/m/ea666f/32.png) [@mschauer](https://forum.shopware.com/u/mschauer)\
**Post date:** [18. April 2015 um 00:48 UTC](https://forum.shopware.com/t/gelost-wawi-import-zugriff-auf-attribute/4045/10 "2015-04-18T00:48:00Z")

</div>

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/](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](mailto:mschauer@solutobusiness.de) Gruß Marco Schauer
