Aufbau der PHP Arrays bei der Shopware REST API
Artikel mit Varianten – GET articles
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
$ordernumber = "123456"; $data = $client->get('articles/'.$ordernumber, array('useNumberAsId'=>'true') ); $data['id'] = 123; $data['mainDetailId'] = 321; $data['supplierId'] = 123; $data['taxId'] = 123; $data['priceGroupId'] = 123; $data['filterGroupId'] = 123; $data['configuratorSetId'] = 123; $data['name'] = "Demo Produkt mit Varianten"; $data['active'] = 1; $data['description'] = "Meta Description"; $data['descriptionLong'] = "HTML Description"; $data['added'] = "2015-01-20T00:00:00+0100"; $data['pseudoSales'] = "0"; $data['highlight'] = ""; $data['keywords'] = ""; $data['metaTitle'] = ""; $data['changed'] = "2015-01-20T01:26:30+0100"; $data['priceGroupActive'] = ""; $data['lastStock'] = ""; $data['crossBundleLook'] = "0"; $data['notification'] = ""; $data['template'] = ""; $data['mode'] = "0"; $data['availableFrom'] = ""; $data['availableTo'] = ""; // Die Varianten. Achtung, beim holen heißt der key details. Bei insert oder update heißt der key variants $data['details'][0]['id'] = 333; $data['details'][0]['articleId'] = 379; $data['details'][0]['unitId'] = ""; $data['details'][0]['number'] = ""; $data['details'][0]['supplierNumber'] = ""; $data['details'][0]['kind'] = 2 ; // $data['details'][0]['additionalText'] = "XS"; $data['details'][0]['active'] = 1; $data['details'][0]['inStock'] = 5; $data['details'][0]['stockMin'] = ""; $data['details'][0]['weight'] = ""; $data['details'][0]['width'] = ""; $data['details'][0]['len'] = ""; $data['details'][0]['height'] = ""; $data['details'][0]['ean'] = ""; $data['details'][0]['position'] = 0; $data['details'][0]['minPurchase'] = ""; $data['details'][0]['purchaseSteps'] = ""; $data['details'][0]['maxPurchase'] = ""; $data['details'][0]['purchaseUnit'] = ""; $data['details'][0]['referenceUnit'] = ""; $data['details'][0]['packUnit'] = ""; $data['details'][0]['shippingFree'] = ""; $data['details'][0]['releaseDate'] = ""; $data['details'][0]['shippingTime'] = "2-5": $data['details'][0]['attribute'] => Array |
Artikel mit eintragen – POST articles
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
$shopwareArticle = array(); $shopwareArticle['name'] = "Demo Produkt mit Varianten"; $shopwareArticle['active'] = 1; $shopwareArticle['taxId'] = 5; // id aus der Tabelle s_core_tax $shopwareArticle['supplier'] = "Demo Hersteller"; $shopwareArticle['lastStock'] = 1; // Abverkauf $shopwareArticle['metaTitle'] = ""; // SEO Meta Titel $shopwareArticle['keywords'] = ""; // SEO Meta Keywords $shopwareArticle['description'] = ""; // SEO Meta Beschreibung $shopwareArticle['descriptionLong'] = ""; // Lange Beschreibung $shopwareArticle['attribute']['attr1'] = ""; // Freitext 1 $shopwareArticle['attribute']['attr2'] = ""; // Freitext 2 /*-------------------------------------------------------------------- Hauptartikel Details --------------------------------------------------------------------*/ $shopwareArticle['mainDetail']['number'] = "XYZ-1234.XL"; $shopwareArticle['mainDetail']['inStock'] = "5" ; // Lagerbestand $shopwareArticle['mainDetail']['shippingTime'] = "3-4"; // Lieferzeit in Tagen $shopwareArticle['mainDetail']['weight'] = ""; $shopwareArticle['mainDetail']['width'] = ""; $shopwareArticle['mainDetail']['height'] = ""; $shopwareArticle['mainDetail']['len'] = ""; /*-------------------------------------------------------------------- Grundpreisberechnung --------------------------------------------------------------------*/ $shopwareArticle['mainDetail']['unitId'] = 2; // Maßeinheit. ID aus der Tabelle s_core_units $shopwareArticle['mainDetail']['purchaseUnit'] = 1; // Inhalt. $shopwareArticle['mainDetail']['referenceUnit'] = 1; // Grundeinheit $shopwareArticle['mainDetail']['packUnit'] = 'Stück'; // Verpackungseinheit /*-------------------------------------------------------------------- Preise --------------------------------------------------------------------*/ $shopwareArticle['mainDetail']['prices'][0]['customerGroupKey'] = "EK"; $shopwareArticle['mainDetail']['prices'][0]['price'] = 137.69119; /*-------------------------------------------------------------------- Kategorien --------------------------------------------------------------------*/ $shopwareArticle['categories'] = array(); $shopwareArticle['categories'][0]['id'] = 323; /*--------------------------------------------------------------------- Eigenschaften -----------------------------------------------------------------------*/ $shopwareArticle['filterGroupId'] = $this->filtergroupID ; $shopwareArticle['propertyValues'] = array(); $shopwareArticle['propertyValues'][0]['option']['name'] = "Größen" $shopwareArticle['propertyValues'][0]['value'] = "XL"; /*-------------------------------------------------------------------- configurator Set --------------------------------------------------------------------*/ $shopwareArticle['configuratorSet']['groups'][0]['name'] = "Größe"; $shopwareArticle['configuratorSet']['groups'][0]['options'] = array(); $shopwareArticle['configuratorSet']['groups'][0]['options'][0]['name'] = "XL"; /*-------------------------------------------------------------------- Varianten --------------------------------------------------------------------*/ $variant = array(); $variant['isMain'] = $i==0 ? 1 : 0 ; // ist Hauptartikel. 1=Ja; 0=Nein $variant['kind'] = $i==0 ? 1 : 2 ; // 1 für Hauptartikel; 2 für Variante $variant['additionaltext'] = "XL"; // Zusatztext für den Namen $variant['active'] = 1 ; $variant['number'] = "XYZ-1234.XL"; $variant['inStock'] = "5" ; // Lagerbestand $variant['shippingtime'] = "3-4"; // Lieferzeit in Tagen. Achtung hier muss ein kleines "t" bei time verwendet werden. $variant['configuratorOptions'][0]['group'] = "Größe"; $variant['configuratorOptions'][0]['option'] = "XL"; $variant['prices'][0]['customerGroupKey'] = 'EK' ; $variant['prices'][0]['price'] = 137.69119; // Netto Preis $variant['attribute']['attr1'] = ""; // Freitext 1 $variant['attribute']['attr2'] = ""; // Freitext 2 $shopwareArticle['variants'][] = $variant; /*-------------------------------------------------------------------- Artikel per RESt Api eintragen --------------------------------------------------------------------*/ $client->post('articles', $shopwareArticle); |
Artikel mit Varianten aktualisieren – PUT articles
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
$data = array(); $data['name'] = "Demo Produkt mit Varianten"; $data['active'] = 1; $data['keywords'] = "META Keywörter"; $data['description'] = "META Beschreibung"; $data['descriptionLong'] = "Beschreibung mit <strong>HTML</strong>"; $updateArticle['shippingtime'] = "7" ; // Eigenschaften Zuordnung $data['filterGroupId'] = 5; // ID des Eigenschaften Sets aus der Tabelle s_filter $data['propertyValues'][0]['option']['name'] = "Colors"; $data['propertyValues'][0]['value'] = "schwarz"; $data['propertyValues'][0]['option']['name'] = "Colors"; $data['propertyValues'][0]['value'] = "weiß"; // $data['configuratorSet']['groups'][0]['name'] = "Size"; $data['configuratorSet']['groups'][0]['options'][0]['name'] = "L"; $data['configuratorSet']['groups'][0]['options'][1]['name'] = "M"; $data['configuratorSet']['groups'][0]['options'][2]['name'] = "XL"; // Als Key variants oder details => da ist irgendwas buggy $data['variants'][0]['kind'] = 1; // 1=Hauptartikel, 2=Variantenartikel $data['variants'][0]['number'] = "XYZ-1234.L" $data['variants'][0]['active'] = 1 $data['variants'][0]['inStock'] = 10 $data['variants'][0]['shippingtime'] = "7"; $data['variants'][0]['additionaltext'] = "L"; $data['variants'][0]['configuratorOptions'][0]['group'] = "Size"; $data['variants'][0]['configuratorOptions'][0]['option'] = "L"; $data['variants'][0]['prices'][0]['customerGroupKey'] = "EK"; $data['variants'][0]['prices'][0]['price'] = 137.69119; // $id = 123; $client->put('articles'.$id, $data); |
Artikel Attribute (Freitext 1 und 2)
1 2 3 |
$data = array(); $data['attribute']['attr1'] => "Material: 100% Cotton"; $data['attribute']['attr2'] => "Farbe: Red"; |