# import von variantenbilder API REST

**URL:** <https://forum.shopware.com/t/import-von-variantenbilder-api-rest/41782>\
**Category:** Programmierung\
**Created:** [28. November 2016 um 14:05 UTC](https://forum.shopware.com/t/import-von-variantenbilder-api-rest/41782 "2016-11-28T14:05:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dutchy](https://avatars.discourse-cdn.com/v4/letter/d/65b543/32.png) [@dutchy](https://forum.shopware.com/u/dutchy)\
**Post date:** [28. November 2016 um 14:05 UTC](https://forum.shopware.com/t/import-von-variantenbilder-api-rest/41782/1 "2016-11-28T14:05:28Z")

</div>

Hallo,  
ich hätte mal wieder ein frage und zwar geht es um den import/update von variantenbilder über die API REST schnittstelle.  
wenn ich die variantenbilder weglasse, läuft der import ohne weiteres durch, wenn ich aber die bilder mit importieren möchte, bricht er ohne fehlermeldung ab:-(  
vielleicht hat ja jemand eine idee oder erfahrung damit, danke:-)

mfg  
dutchy

---

<div class="post-metadata">

**Author:** ![hhmarco](https://avatars.discourse-cdn.com/v4/letter/h/e56c9b/32.png) [@hhmarco](https://forum.shopware.com/u/hhmarco)\
**Post date:** [28. November 2016 um 18:31 UTC](https://forum.shopware.com/t/import-von-variantenbilder-api-rest/41782/2 "2016-11-28T18:31:31Z")

</div>

Wie sieht denn Dein POST Request aktuell aus?

---

<div class="post-metadata">

**Author:** ![dutchy](https://avatars.discourse-cdn.com/v4/letter/d/65b543/32.png) [@dutchy](https://forum.shopware.com/u/dutchy)\
**Post date:** [28. November 2016 um 19:11 UTC](https://forum.shopware.com/t/import-von-variantenbilder-api-rest/41782/3 "2016-11-28T19:11:49Z")

</div>

Hallo Marco,  
folgendes array übergebe ich z.b. beim updaten der methode “put”.  
das ist jetzt ein array mit einer variante.  
danke für deine mühe:-)  
mfg  
dutchy

```
Array
(
    [name] => name
    [active] => 1
    [tax] => 19
    [supplier] => supplier
    [description] => description
    [descriptionLong] => descriptionLong
    [keywords] => keywords
    [metaTitle] => metaTitle
    [pseudoSales] => 11900
    [highlight] => 0
    [lastStock] => 1
    [mainDetail] => Array
        (
            [active] => 1
            [number] => LMG-XXX
            [inStock] => 0
            [shippingTime] => ca. 2-3 Wochen
            [weight] => 1.6
            [height] => 0
            [width] => 0
            [len] => 0
            [releaseDate] => 2011-04-18
            [added] => 2011-04-18
            [ean] => 654654654
            [additionaltext] => 
            [prices] => Array
                (
                    [0] => Array
                        (
                            [customerGroupKey] => EK
                            [from] => 1
                            [to] => beliebig
                            [price] => 10
                            [pseudoprice] => 0
                        )
                )
            [attribute] => Array
                (
                    [attr1] => text
                    [attr2] => text
                )
        )
    [images] => Array
        (
            [0] => Array
                (
                    [link] => http://www.xxx.de/bilder/bild-1778.jpg
                    [description] => description
                    [main] => 1
                )

            [1] => Array
                (
                    [link] => http://www.xxx.de/bilder/bild-1779.jpg
                    [description] => description
                    [main] => 2
                )

        )
    [filterGroupId] => 71
    [propertyValues] => Array
        (
            [0] => Array
                (
                    [option] => Array
                        (
                            [name] => Gruppe
                            [filterable] => 1
                        )

                    [value] => ledergenarbt
                    [position] => 1
                )
        )
    [configuratorSet] => Array
        (
            [groups] => Array
                (
                    [0] => Array
                        (
                            [name] => Farbe
                            [options] => Array
                                (
                                    [0] => Array
                                        (
                                            [name] => blau
                                        )

                                    [1] => Array
                                        (
                                            [name] => bordeaux
                                        )

                                    [2] => Array
                                        (
                                            [name] => dunkelblau
                                        )

                                    [3] => Array
                                        (
                                            [name] => grau
                                        )

                                )
                        )
                    [1] => Array
                        (
                            [name] => Rückenbreite
                            [options] => Array
                                (
                                    [0] => Array
                                        (
                                            [name] => 1,5 mm
                                        )

                                    [1] => Array
                                        (
                                            [name] => 2 mm
                                        )

                                    [2] => Array
                                        (
                                            [name] => 3 mm
                                        )

                                    [3] => Array
                                        (
                                            [name] => 4 mm
                                        )

                                )
                        )
                )
        )
    [categories] => Array
        (
            [0] => Array
                (
                    [id] => 38
                )

            [1] => Array
                (
                    [id] => 83
                )

        )
    [variants] => Array
        (          
            [0] => Array
                (
                    [number] => LMG-XXX-DBL-R6
                    [active] => 1
                    [kind] => 2
                    [inStock] => 422
                    [shippingTime] => ca. 2-3 Wochen
                    [weight] => 1.6
                    [height] => 0.6
                    [width] => 21.5
                    [len] => 29.5
                    [releaseDate] => 2011-04-18
                    [added] => 2011-04-18
                    [ean] => 
                    [additionaltext] => Rückenbreite: 6 mm
                    [prices] => Array
                        (
                            [0] => Array
                                (
                                    [customerGroupKey] => H
                                    [from] => 1
                                    [to] => beliebig
                                    [price] => 9.5
                                    [pseudoprice] => 0
                                )

                            [1] => Array
                                (
                                    [customerGroupKey] => EK
                                    [from] => 1
                                    [to] => beliebig
                                    [price] => 12.49
                                    [pseudoprice] => 0
                                )
                        )
                    [images] => Array
                        (
                            [0] => Array
                                (
                                    [link] => http://www.www.de/bilder/bild-1840.jpg
                                    [description] => description
                                    [main] => 1
                                )
                        )
                    [configuratorOptions] => Array
                        (
                            [0] => Array
                                (
                                    [group] => Farbe
                                    [option] => dunkelblau
                                )
                            [1] => Array
                                (
                                    [group] => Rückenbreite
                                    [option] => 6 mm
                                )
                        )
                    [attribute] => Array
                        (
                            [attr1] => text
                            [attr2] => 50 Stück
                        )
                )
        )
    [customerGroups] => 
)

```

&nbsp;

---

<div class="post-metadata">

**Author:** ![dutchy](https://avatars.discourse-cdn.com/v4/letter/d/65b543/32.png) [@dutchy](https://forum.shopware.com/u/dutchy)\
**Post date:** [1. Dezember 2016 um 11:03 UTC](https://forum.shopware.com/t/import-von-variantenbilder-api-rest/41782/4 "2016-12-01T11:03:33Z")

</div>

Hallo in die Runde,  
ich bin jetzt ein schritt weiter, die zuordnung der bilder erfolgt über den tag “relations”.  
ich kann jetzt die variantenbilder importieren und das bild der jeweiligen variante zuordnen.  
wenn ich jetzt den artikel per get aufrufe, bekomme ich folgendes:

&nbsp;&nbsp; [images] =\> Array  
&nbsp;&nbsp;&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [extension] =\> jpg  
&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; [parentId] =\>  
&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; [mediaId] =\> 30298  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )

Das problem was ich jetzt noch habe, wenn ich die artikelvariante aufrufe im frontend des shops, bekomme ich alle bilder der einzelnen varianten zusehen.  
habt ihr eine idee, wie ich es schaffe, dass er nur die bilder anzeigt, die zur variante passen?  
danke schonmal:-)

mfg  
dutchy

---

<div class="post-metadata">

**Author:** ![C\_lemens](https://avatars.discourse-cdn.com/v4/letter/c/e5b9ba/32.png) [@C\_lemens](https://forum.shopware.com/u/C_lemens)\
**Post date:** [26. Juni 2018 um 07:11 UTC](https://forum.shopware.com/t/import-von-variantenbilder-api-rest/41782/5 "2018-06-26T07:11:43Z")

</div>

Hallo&nbsp;dutchy,

Ich nehme zwar nicht an, dass du noch immer keine Lösung hast, jedoch will ich die Antwort für all jene geben, die auf diesen Post stoßen sollten.

Man kann einem Bild bei PUT oder POST einen Array ‚options‘ übergeben, der dann die Options der zugehörigen Varianten enthält.

&nbsp;Wenn du z.B.: dein erstes Bild den Varianten zuteilen willst, die „rot“ sind oder „blau mit inhalt 0,5l“ dann schaut dein Array wiefolgt aus:

&nbsp;

[images] =\> Array (

&nbsp; &nbsp;[0] =\> Array (

&nbsp; &nbsp; &nbsp; &nbsp; [link] =\> [http://www.xxx.de/bilder/bild-1778.jpg](http://www.xxx.de/bilder/bild-1778.jpg)

&nbsp; &nbsp; &nbsp; &nbsp; [description] =\> description

&nbsp; &nbsp; &nbsp; &nbsp; [main] =\> 1

&nbsp; &nbsp; &nbsp; **&nbsp; [options] =\> Array(**

**&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Array(**

**&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Array([name] =\> ‚0,5 Liter‘),**

**&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // AND**

**&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Array([name] =\> ‚blau‘)**

**&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ),**

**&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // OR**

**&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Array( Array([name] =\> ‚rot‘) )**

**&nbsp; &nbsp; &nbsp; &nbsp; )**

)

Da Shopware die Performance verbessern will, muss man nach diesem API Aufruf nochmal einen API Aufruf machen:

PUT /api/generateArticleImages/ID oder&nbsp;PUT /api/generateArticleImages/SKU?useNumberAsId=true

&nbsp;

All das findest du auch in der tollen Doku von Shopware:&nbsp;[REST API - Examples using the media resource](https://developers.shopware.com/developers-guide/rest-api/examples/media/)

&nbsp;

LG&nbsp;
