REST-API : Varianten aktualisieren

Hallo, ich habe ein Problem beim Aktualisieren von Varianten / Configurations. Und zwar wird der MainDetail Datensatz des Hauptartikels physikalisch gelöscht, der Verweis in der Tabelle „s_articles“ in der Spalte „main_detail_id“ bleibt jedoch auf dem gelöschten Fremdschlüssel bestehen. Mein Aktualisierungs-Request der Variante sieht wiefolgt aus: { "supplierId": 6, "taxId": 1, "pseudoSales": 33, "keywords": "Test", "name": "Testartikel MSC", "description": "Kurzbeschreibung!", "descriptionLong": "", "added": "2013-09-26T00:00:00+0200", "changed": "2013-10-14T08:52:12+0200", "active": true, "highlight": true, "lastStock": true, "notification": false, "mainDetail": { "active": 1, "inStock": 10, "purchaseSteps": 0, "minPurchase": 1, "maxPurchase": 8, "weight": 4400, "width": 1110, "len": 3330, "height": 6660, "number": "MSC-001", "supplierNumber": "HER111", "ean": "EAN777", "shippingTime": "", "releaseDate": "", "shippingFree": true, "kind": 1, "prices": [{ "from": 1, "customerGroupKey": "EK", "to": "beliebig", "price": 28.1, "pseudoPrice": 0, "basePrice": 0, "percent": 0 }] }, "configuratorSet": { "groups": [{ "name": "Größe", "options": [{"name": "M"}, {"name": "L"}, {"name": "XL"}, {"name": "XXL"}, {"name": "S"}] }], "type": 1 }, "images": [{ "link": "http://test.jpg", "main": true }, { "link": "test.jpg", "main": false }], "variants": [{ "active": 1, "inStock": 10, "minPurchase": 1, "maxPurchase": 8, "weight": 4400, "width": 1110, "len": 3330, "height": 6660, "number": "MSC-001", "supplierNumber": "HER111", "additionalText": "Größe: XXL; ", "ean": "EAN777", "shippingTime": "", "shippingFree": true, "isMain": true, "prices": [{ "from": 1, "customerGroupKey": "EK", "to": "beliebig", "price": 28.1, "pseudoPrice": 0, "basePrice": 0, "percent": 0 }], "configuratorOptions": [{ "group": "Größe", "option": "XXL" }], "offerId": 33986 }, { "active": 1, "inStock": 6, "minPurchase": 1, "maxPurchase": 8, "weight": 4400, "width": 1110, "len": 3330, "height": 6660, "number": "MSC-002", "supplierNumber": "HER111", "additionalText": "Größe: XL; ", "ean": "EAN777", "shippingTime": "", "shippingFree": true, "isMain": false, "prices": [{ "from": 1, "customerGroupKey": "EK", "to": "beliebig", "price": 28.1, "pseudoPrice": 0, "basePrice": 0, "percent": 0 }], "configuratorOptions": [{ "group": "Größe", "option": "XL" }], "offerId": 33987 }, { "active": 1, "inStock": 10, "minPurchase": 1, "maxPurchase": 8, "weight": 4400, "width": 1110, "len": 3330, "height": 6660, "number": "MSC-003", "supplierNumber": "HER111", "additionalText": "Größe: S; ", "ean": "EAN777", "shippingTime": "", "shippingFree": true, "isMain": false, "prices": [{ "from": 1, "customerGroupKey": "EK", "to": "beliebig", "price": 28.1, "pseudoPrice": 0, "basePrice": 0, "percent": 0 }], "configuratorOptions": [{ "group": "Größe", "option": "S" }], "offerId": 33988 }, { "active": 1, "inStock": 4, "minPurchase": 1, "maxPurchase": 8, "weight": 4400, "width": 1110, "len": 3330, "height": 6660, "number": "MSC-004", "supplierNumber": "HER111", "additionalText": "Größe: M; ", "ean": "EAN777", "shippingTime": "", "shippingFree": true, "isMain": false, "prices": [{ "from": 1, "customerGroupKey": "EK", "to": "beliebig", "price": 28.1, "pseudoPrice": 0, "basePrice": 0, "percent": 0 }], "configuratorOptions": [{ "group": "Größe", "option": "M" }], "offerId": 33989 }, { "active": 1, "inStock": 10, "minPurchase": 1, "maxPurchase": 8, "weight": 4400, "width": 1110, "len": 3330, "height": 6660, "number": "MSC-005", "supplierNumber": "HER111", "additionalText": "Größe: L; ", "ean": "EAN777", "shippingTime": "", "shippingFree": true, "isMain": false, "prices": [{ "from": 1, "customerGroupKey": "EK", "to": "beliebig", "price": 28.1, "pseudoPrice": 0, "basePrice": 0, "percent": 0 }], "configuratorOptions": [{ "group": "Größe", "option": "L" }], "offerId": 33990 } ], "categories": {"14": {"id": 14}} } Nach Recherche im Source-Code (Datei Shoproot/engine/Shopware/Components/Api/Resource/Article) konnte ich feststellen, dass in der Zeile 577 eine Prüfung enthalten ist, die für die Löschung des MainDetails verantwortlich ist. Und zwar wird hier geprüft, ob das übergebene MainDetail im Request „configuratorOptions“ hat. Dies ist in meinem Fall nicht so und folglich wird deshalb das MainDetail gelöscht. Im nächsten Schritt habe ich einfach im Hauptartikel MainDetail die Options des ersten Unterartikels angegeben, in der Hoffnung, dass so die Löschung verhindert wird. Der Request sah dann wiefolgt aus: { "supplierId": 6, "taxId": 1, "pseudoSales": 33, "keywords": "Speed4Trade", "name": "Testartikel MSC", "description": "Kurzbeschreibung!", "descriptionLong": "", "added": "2013-09-26T00:00:00+0200", "changed": "2013-10-14T08:52:12+0200", "active": true, "highlight": true, "lastStock": true, "notification": false, "mainDetail": { "active": 1, "inStock": 10, "purchaseSteps": 0, "minPurchase": 1, "maxPurchase": 8, "weight": 4400, "width": 1110, "len": 3330, "height": 6660, "number": "MSC-001", "supplierNumber": "HER111", "ean": "EAN777", "shippingTime": "", "releaseDate": "", "shippingFree": true, "kind": 1, "prices": [{ "from": 1, "customerGroupKey": "EK", "to": "beliebig", "price": 28.1, "pseudoPrice": 0, "basePrice": 0, "percent": 0 }], "configuratorOptions": [{ "group": "Größe", "option": "XXL" }] }, "configuratorSet": { "groups": [{ "name": "Größe", "options": [{"name": "M"}, {"name": "L"}, {"name": "XL"}, {"name": "XXL"}, {"name": "S"}] }], "type": 1 }, "images": [{ "link": "http://i1.ytimg.com/i/ZBaZGhS4VmtYqnDqg8G\_QQ/mq1.jpg", "main": true }, { "link": "http://www.speed4trade.com/files/p1000069-1-klein.jpg", "main": false }], "variants": [{ "active": 1, "inStock": 10, "minPurchase": 1, "maxPurchase": 8, "weight": 4400, "width": 1110, "len": 3330, "height": 6660, "number": "MSC-001", "supplierNumber": "HER111", "additionalText": "Größe: XXL; ", "ean": "EAN777", "shippingTime": "", "shippingFree": true, "isMain": true, "prices": [{ "from": 1, "customerGroupKey": "EK", "to": "beliebig", "price": 28.1, "pseudoPrice": 0, "basePrice": 0, "percent": 0 }], "configuratorOptions": [{ "group": "Größe", "option": "XXL" }], "offerId": 33986 }, { "active": 1, "inStock": 6, "minPurchase": 1, "maxPurchase": 8, "weight": 4400, "width": 1110, "len": 3330, "height": 6660, "number": "MSC-002", "supplierNumber": "HER111", "additionalText": "Größe: XL; ", "ean": "EAN777", "shippingTime": "", "shippingFree": true, "isMain": false, "prices": [{ "from": 1, "customerGroupKey": "EK", "to": "beliebig", "price": 28.1, "pseudoPrice": 0, "basePrice": 0, "percent": 0 }], "configuratorOptions": [{ "group": "Größe", "option": "XL" }], "offerId": 33987 }, { "active": 1, "inStock": 10, "minPurchase": 1, "maxPurchase": 8, "weight": 4400, "width": 1110, "len": 3330, "height": 6660, "number": "MSC-003", "supplierNumber": "HER111", "additionalText": "Größe: S; ", "ean": "EAN777", "shippingTime": "", "shippingFree": true, "isMain": false, "prices": [{ "from": 1, "customerGroupKey": "EK", "to": "beliebig", "price": 28.1, "pseudoPrice": 0, "basePrice": 0, "percent": 0 }], "configuratorOptions": [{ "group": "Größe", "option": "S" }], "offerId": 33988 }, { "active": 1, "inStock": 4, "minPurchase": 1, "maxPurchase": 8, "weight": 4400, "width": 1110, "len": 3330, "height": 6660, "number": "MSC-004", "supplierNumber": "HER111", "additionalText": "Größe: M; ", "ean": "EAN777", "shippingTime": "", "shippingFree": true, "isMain": false, "prices": [{ "from": 1, "customerGroupKey": "EK", "to": "beliebig", "price": 28.1, "pseudoPrice": 0, "basePrice": 0, "percent": 0 }], "configuratorOptions": [{ "group": "Größe", "option": "M" }], "offerId": 33989 }, { "active": 1, "inStock": 10, "minPurchase": 1, "maxPurchase": 8, "weight": 4400, "width": 1110, "len": 3330, "height": 6660, "number": "MSC-005", "supplierNumber": "HER111", "additionalText": "Größe: L; ", "ean": "EAN777", "shippingTime": "", "shippingFree": true, "isMain": false, "prices": [{ "from": 1, "customerGroupKey": "EK", "to": "beliebig", "price": 28.1, "pseudoPrice": 0, "basePrice": 0, "percent": 0 }], "configuratorOptions": [{ "group": "Größe", "option": "L" }], "offerId": 33990 } ], "categories": {"14": {"id": 14}} } Nun erhalte ich jedoch die Fehlermeldung „Found entity of type on association Shopware\Models\Article\Detail#configuratorOptions, but expecting Shopware\Models\Article\Configurator\Option“}" Muss der „configuratorOptions“ Block beim Hauptartikel MainDetail anders strukturiert übergeben werden? Könnt ihr mir bitte einen Request posten, der Varianten mit configurationSet aktualisiert? Vielen Dank im Voraus für euer Feedback!

Hat hier an dieser Stelle noch niemand einen Artikel mit Konfigurationsdaten aktualisiert? Leider findet sich hierzu keinerlei Beispiel in der Dokumentation! Wir benötigen jedoch das Akutalisieren, um z.B. neue Ausprägungen einzubinden. Über ein kurzes Feedback bzw. einen Lösungsansatz würde ich mich sehr freuen!

Hallo MSC Konntest du dein Problem bereits lösen? Bin auch gerade auf der Lösungssuche mit dem selben Problem. Die Varianten auch HauptArtikel lassen sich grundsätzlich aktualisieren. Beim aktualisieren gebe ich den HauptArtikel nur als mainArticle an (nicht unter variants) und ohne configuratorOptions. { "id": 4386, "supplier": "Sonnenreiter", "name": "Softshelljacke Leeds Damen - gelb", "description": "", "descriptionLong": "", "added": "2013-12-10T00:00:00+0100", "active": true, "highlight": false, "keywords": "Sonnenreiter, Softshelljacke Leeds, Reitbekleidung, Pferdesport, Reitsport", "lastStock": false, "notification": false, "configuratorSet": { "groups": [{ "name": "\*Grösse Bekleidung Damen", "options": [ { "name": "S" }, { "name": "M" }, { "name": "L" }] } ] }, "mainDetail": { "number": "A30605801", "supplierNumber": "", "isMain": true, "additionalText": "S", "active": 1, "inStock": 1, "ean": "4052539177995", "prices": [{ "customerGroupKey": "EK", "price": 225 }], "attribute": { "attr5": "false", "tonurArticleGiftOption": false } }, "tax": { "tax": 8 }, "categories": { "236": { "id": 236 } }, "related": [], "similar": [], "propertyValues": [{ "option": { "name": "Geschlecht" }, "value": "Damen" }, { "option": { "name": "Farbe" }, "value": "Gelb" }], "filterGroupId": 3, "variants": [{ "number": "A30605802", "supplierNumber": "", "isMain": false, "additionalText": "M", "active": 1, "inStock": 1, "ean": "4052539178008", "prices": [ { "customerGroupKey": "EK", "price": 225 }], "configuratorOptions": [{ "group": "\*Grösse Bekleidung Damen", "option": "M" }] }, { "number": "A30605803", "supplierNumber": "", "isMain": false, "additionalText": "L", "active": 1, "inStock": 1, "ean": "4052539178015", "prices": [{ "customerGroupKey": "EK", "price": 225 }], "configuratorOptions": [{ "group": "\*Grösse Bekleidung Damen", "option": "L" }] } ], "translations": { "2": { "shopId": 2, "name": "Veste Softshell Leeds Dames- jaune", "description": "", "descriptionLong": "", "keywords": "Sonnenreiter, Softshelljacke Leeds, Reitbekleidung, Pferdesport, Reitsport" } } } Jedoch versuche ich jetzt die configuratorOptions beim HauptArtikel anzupassen, bzw. die Grösse zu ändern. Hier taucht nun selbiges Problem wie bei dir auf. Hoffe jemand hat eine Lösung bereit. Lg Christian

Hi guys, I have the same problem with version 4.1.4. Have you found solution for this problem? Many thanks, Petar

Nachdem ich das identische Problem hatte, wollte ich nur kurz sagen, dass es in Version 4.2 zu funktionieren scheint. Allerdings nur dann, wenn man die configuratorOptions der Primärvariante bei einem Update (PUT) in den main article integriert, aber beim originalen anlegen (POST) weglässt. Beispiel JSON hier: "configuratorOptions":[{"group":"Farbe","option":"weiss"}] Schaden kann es auch nicht, die IDs für die Varianten richtig zu setzten. Komplettes JSON für Update, das funkioniert: {"active":true,"categories":[{"id":18},{"id":5},{"id":15}],"configuratorSet":{"groups":[{"name":"Farbe","options":[{"name":"multicolor"},{"name":"weiss"}]}]},"description":"Geschirrset aus der Serie Vital von Ornamin","descriptionLong":"Alle Teile ...","filterGroupId":1,"id":55,"mainDetail":{"attribute":{"attr1":"\u2026 dieses Geschirrset ein besonders gelungenes Beispiel dafür darstellt, wie formschönes Design und durchdachte Funktionalität miteinander verbunden werden können. Dies haben auch die Jurys von mehreren international renommierten Design-Preisen gewürdigt."},"configuratorOptions":[{"group":"Farbe","option":"weiss"}],"id":76,"inStock":8,"number":"FM1400012-S00001","prices":[{"customerGroupKey":"EK","price":0}],"shippingTime":6},"name":"Geschirrset","number":"FM1400012-S00002","propertyValues":[{"option":{"name":"Mehrwert"},"value":"Kraft sparen"},{"option":{"name":"Mehrwert"},"value":"Leicht greifen"}],"supplier":"Ornamin Pro Vita","taxId":1,"variants":[{"active":1,"additionaltext":"Geschirrset weiss","articleId":55,"configuratorOptions":[{"group":"Farbe","option":"weiss"}],"id":76,"inStock":0,"isMain":true,"number":"FM1400012-S00001","prices":[{"customerGroupKey":"EK","price":58.95000076293945}]},{"active":1,"additionaltext":"Geschirrset multicolor","articleId":55,"configuratorOptions":[{"group":"Farbe","option":"multicolor"}],"inStock":0,"number":"FM1400012-S00002","prices":[{"customerGroupKey":"EK","price":58.95000076293945}]}]}