# Alle Artikelbilder-IDs auslesen?

**URL:** https://forum.shopware.com/t/alle-artikelbilder-ids-auslesen/48521
**Category:** Programmierung
**Created:** [27. September 2017 um 13:37 UTC](https://forum.shopware.com/t/alle-artikelbilder-ids-auslesen/48521 "2017-09-27T13:37:52Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Benziner](https://avatars.discourse-cdn.com/v4/letter/b/c37758/32.png) [@Benziner](https://forum.shopware.com/u/Benziner)
#### Post date: [27. September 2017 um 13:37 UTC](https://forum.shopware.com/t/alle-artikelbilder-ids-auslesen/48521/1 "2017-09-27T13:37:52Z")

</div>

&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;$params = [  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;‚filter‘ =\> array(  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;array(  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;‚property‘ =\> ‚name‘,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;‚value‘ =\> ‚artikel‘,  
&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; &nbsp;&nbsp;&nbsp; &nbsp;$ergebnis3 = $client-\>get(‚media‘,$params);

&nbsp;

Hi ich versuche alle Artikelbilder aus den Media auszulesen (um sie anschließend zu löschen). Dabei will ich wirklich nur die MediaID und nur die Medien, die Artikelbilder sind. Andere will ich nicht, da ich die sonst wieder einfügen müsste.

Nun habe ich es versucht wie es oben dran steht und bekomme aber diesen Fehler:

&nbsp;

> Error message: [Syntax Error] line 0, col 58: Error: Expected ‚.‘ or ‚(‘, got ‚name‘

&nbsp;

Wie muss ich den Filter abwandeln, dass ich nur die Artikelbilder bekomme? (Also deren MediaId)

---

<div class="post-metadata">

### Author: ![IFF](https://avatars.discourse-cdn.com/v4/letter/i/c37758/32.png) [@IFF](https://forum.shopware.com/u/IFF)
#### Post date: [28. September 2017 um 10:16 UTC](https://forum.shopware.com/t/alle-artikelbilder-ids-auslesen/48521/2 "2017-09-28T10:16:16Z")

</div>

Schau mal hier:

[https://developers.shopware.com/developers-guide/rest-api/api-resource-media/](https://developers.shopware.com/developers-guide/rest-api/api-resource-media/)

Hierzu brauchst du die MediaID die über “articles” mit angezeigt wird.

Ein Beispiel mit Artikel 12345:

// per API nach Artikel abfragen, um an die mediaID zu kommen  
$out = $client-\>get(‘articles/12345’);

// im Array ein Bild gefunden  
$mediaId = $out[‘images’][0][‘mediaId’];

// Bildinfo zur mediaId abholen  
$img = $client-\>get(‘media/’.$mediaId);

// und dann eben die Thumbnails löschen + IDs aus DB usw. usw.  
&nbsp;

---

<div class="post-metadata">

### Author: ![WillemMeert](https://avatars.discourse-cdn.com/v4/letter/w/5daacb/32.png) [@WillemMeert](https://forum.shopware.com/u/WillemMeert)
#### Post date: [30. September 2017 um 20:49 UTC](https://forum.shopware.com/t/alle-artikelbilder-ids-auslesen/48521/3 "2017-09-30T20:49:15Z")

</div>

Hatte dasselbe problem auch schon. Hier das Antwort:&nbsp;&nbsp;[https://forum.shopware.com/discussion/44969/rest-api-media-resource-abfragen-mit-filter](https://forum.shopware.com/discussion/44969/rest-api-media-resource-abfragen-mit-filter)

Mit deinem Syntax:

```
$params = [
            'filter' => array(
                array(
                    'property' => 'media.albumId',
                    'value' => '-1',
                ),
            )
        ];

```

Also alle Media wovon das AlbumId == -1 (-1 entspricht die Artikel).
