# \[gelöst\] Shopware API PHP Client Artikel Import Error

**URL:** <https://forum.shopware.com/t/geloest-shopware-api-php-client-artikel-import-error/49994>\
**Category:** Programmierung\
**Created:** [13. Dezember 2017 um 08:14 UTC](https://forum.shopware.com/t/geloest-shopware-api-php-client-artikel-import-error/49994 "2017-12-13T08:14:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![logTom](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/logtom/32/13273_2.png) [@logTom](https://forum.shopware.com/u/logTom)\
**Post date:** [13. Dezember 2017 um 08:14 UTC](https://forum.shopware.com/t/geloest-shopware-api-php-client-artikel-import-error/49994/1 "2017-12-13T08:14:22Z")

</div>

Shopware API PHP Client Artikel Import Error

Ich versuche über die API Artikel zu importieren. Klappt soweit ganz gut, nur nun gibt es einen Artikel da bekomme ich keine Fehlermeldung mit der ich etwas anfangen kann.

Das ist der Aufruf:

$client-\>put(‘articles/’, $articles);

Das erhalte ich dabei:

## HTTP: 500

## No Success

Error message: You have requested a synthetic service (“db\_connection”). The DIC does not know how to construct this service.

Im Shopware Backend habe ich folgendes dazu gefunden:  
Shopware System-Log: core:

Symfony\Component\DependencyInjection\Exception\RuntimeException: You have requested a synthetic service (“db\_connection”). The DIC does not know how to construct this service. in /mnt/disks/shopware/www.globo-lighting.com/var/cache/production\_201710241020/proxies/ShopwareProductione148d313d1fcea6ccfea63c681a4d03a73a1afbdProjectContainer.php:884 Stack trace:  
#0 /vendor/symfony/dependency-injection/Container.php(304): ShopwareProductione148d313d1fcea6ccfea63c681a4d03a73a1afbdProjectContainer-\>getDbConnectionService()  
#1 /engine/Shopware/Components/DependencyInjection/Container.php(217): Symfony\Component\DependencyInjection\Container-\>get(‘db\_connection’, 2)  
#2 /engine/Shopware/Components/DependencyInjection/Container.php(167): Shopware\Components\DependencyInjection\Container-\>doLoad(‘db\_connection’)  
#3 /engine/Shopware/Components/Api/Resource/Resource.php(589): Shopware\Components\DependencyInjection\Container-\>load(‘db\_connection’)  
#4 /engine/Shopware/Components/Api/Resource/Resource.php(330): Shopware\Components\Api\Resource\Resource-\>resetEntityManager()  
#5 /engine/Shopware/Controllers/Api/Rest.php(79): Shopware\Components\Api\Resource\Resource-\>batch(Array)  
#6 /engine/Library/Enlight/Controller/Action.php(159): Shopware\_Controllers\_Api\_Rest-\>batchAction()  
#7 /engine/Library/Enlight/Controller/Dispatcher/Default.php(530): Enlight\_Controller\_Action-\>dispatch(‘batchAction’)  
#8 /engine/Library/Enlight/Controller/Front.php(223): Enlight\_Controller\_Dispatcher\_Default-\>dispatch(Object(Enlight\_Controller\_Request\_RequestHttp), Object(Enlight\_Controller\_Response\_ResponseHttp))  
#9 /engine/Shopware/Kernel.php(189): Enlight\_Controller\_Front-\>dispatch()  
#10 /vendor/symfony/http-kernel/HttpCache/HttpCache.php(491): Shopware\Kernel-\>handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)  
#11 /engine/Shopware/Components/HttpCache/AppCache.php(268): Symfony\Component\HttpKernel\HttpCache\HttpCache-\>forward(Object(Symfony\Component\HttpFoundation\Request), true, NULL)  
#12 /vendor/symfony/http-kernel/HttpCache/HttpCache.php(258): Shopware\Components\HttpCache\AppCache-\>forward(Object(Symfony\Component\HttpFoundation\Request), true)  
#13 /vendor/symfony/http-kernel/HttpCache/HttpCache.php(275): Symfony\Component\HttpKernel\HttpCache\HttpCache-\>pass(Object(Symfony\Component\HttpFoundation\Request), true)  
#14 /engine/Shopware/Components/HttpCache/AppCache.php(143): Symfony\Component\HttpKernel\HttpCache\HttpCache-\>invalidate(Object(Symfony\Component\HttpFoundation\Request), true)  
#15 /vendor/symfony/http-kernel/HttpCache/HttpCache.php(206): Shopware\Components\HttpCache\AppCache-\>invalidate(Object(Symfony\Component\HttpFoundation\Request), true)  
#16 /engine/Shopware/Components/HttpCache/AppCache.php(116): Symfony\Component\HttpKernel\HttpCache\HttpCache-\>handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)  
#17 /mnt/disks/shopware/www.globo-lighting.com/shopware.php(118): Shopware\Components\HttpCache\AppCache-\>handle(Object(Symfony\Component\HttpFoundation\Request))  
#18 {main}

Hier ist ein var\_dump des oben angeführten $articles Array.

> **[array(1) { \[0\]=\> array(9) { \["categories"\]=\> array(7) { \[...](https://pastebin.com/trutwN4v)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

(Ausgelagert auf Pastebin da zu lange fürs Forum (Body is 10363 characters too long.))

PS: Als ich auf “Show popular tags” klickte um Tags zum Post hinzuzufügen hat der Browser die Seite neu geladen und meinen ganzen Text gelöscht.

&nbsp;

---

<div class="post-metadata">

**Author:** ![PStadtfeld](https://avatars.discourse-cdn.com/v4/letter/p/3bc359/32.png) [@PStadtfeld](https://forum.shopware.com/u/PStadtfeld)\
**Post date:** [13. Dezember 2017 um 09:13 UTC](https://forum.shopware.com/t/geloest-shopware-api-php-client-artikel-import-error/49994/2 "2017-12-13T09:13:35Z")

</div>

Die Struktur des Arrays sieht merkwürdig aus… Selbst auf „See Original“ unter „Raw Output“ scheint mir das noch etwas konfus.

Beim Import versuchst du demnach ein Post über die API abzusetzen, richtig? Hast du mal hier geschaut [https://developers.shopware.com/developers-guide/rest-api/examples/article/](https://developers.shopware.com/developers-guide/rest-api/examples/article/) ?

Beim Zusammenbauen darauf achten, dass du die Knotenpunkte auch alle richtig benennst.

---

<div class="post-metadata">

**Author:** ![logTom](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/logtom/32/13273_2.png) [@logTom](https://forum.shopware.com/u/logTom)\
**Post date:** [13. Dezember 2017 um 09:19 UTC](https://forum.shopware.com/t/geloest-shopware-api-php-client-artikel-import-error/49994/3 "2017-12-13T09:19:40Z")

</div>

Danke, ja haben das ja alles nach Doku aufgebaut und hat bisher bei ca. 8000 Artikeln geklappt. Nur bei diesem hier nicht. Ist kein POST sondern ein PUT wie es für den BATCH Mode angeführt ist. Siehe hier: [REST API - Examples using the batch mode](https://developers.shopware.com/developers-guide/rest-api/examples/batch/)

---

<div class="post-metadata">

**Author:** ![PStadtfeld](https://avatars.discourse-cdn.com/v4/letter/p/3bc359/32.png) [@PStadtfeld](https://forum.shopware.com/u/PStadtfeld)\
**Post date:** [13. Dezember 2017 um 11:41 UTC](https://forum.shopware.com/t/geloest-shopware-api-php-client-artikel-import-error/49994/4 "2017-12-13T11:41:46Z")

</div>

Hm… Ich habe über Put-Batch noch nie Artikel angelegt, aber das Array sollte auch dabei die gleiche Form wie in einem Post haben, nur eben mit einer weiteren Ebene drüber. Gib dir doch mal aus deiner Rückgabe den Strang mit dem einen Artikel über "

```
".print\_r($deinArray,true)."

```

" aus, dann sieht du was er versucht einzuspielen (deutlicher).

---

<div class="post-metadata">

**Author:** ![logTom](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/logtom/32/13273_2.png) [@logTom](https://forum.shopware.com/u/logTom)\
**Post date:** [14. Dezember 2017 um 10:24 UTC](https://forum.shopware.com/t/geloest-shopware-api-php-client-artikel-import-error/49994/5 "2017-12-14T10:24:02Z")

</div>

Wir haben das Problem nun gefunden.

Wir hatten 2 mal das selbe Property im Array, hier der Auszug:

[„propertyValues“]=\>  
&nbsp;&nbsp;&nbsp; array(16) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [4]=\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; array(2) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [„option“]=\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; array(1) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb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nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string(5) „Farbe“  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [„value“]=\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string(4) „grau“  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp; }

&nbsp;

---

<div class="post-metadata">

**Author:** ![logTom](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/logtom/32/13273_2.png) [@logTom](https://forum.shopware.com/u/logTom)\
**Post date:** [14. Dezember 2017 um 10:29 UTC](https://forum.shopware.com/t/geloest-shopware-api-php-client-artikel-import-error/49994/6 "2017-12-14T10:29:59Z")

</div>

Wie kann ich den Thread als beantwortet markieren?

---

<div class="post-metadata">

**Author:** ![PStadtfeld](https://avatars.discourse-cdn.com/v4/letter/p/3bc359/32.png) [@PStadtfeld](https://forum.shopware.com/u/PStadtfeld)\
**Post date:** [14. Dezember 2017 um 11:40 UTC](https://forum.shopware.com/t/geloest-shopware-api-php-client-artikel-import-error/49994/7 "2017-12-14T11:40:20Z")

</div>

Müsstest entweder eine Antwort als „hat meine Frage beantwortet“ markieren oder schreib einfach [gelöst] oder so davor.
