Bestellungen importieren
Während dieses Prozesses werden Bestellungen für den Shop abgerufen und der erfolgreiche Bestellimport an Channel Pilot Pro gemeldet. Dabei werden Bestellnummer und Bestellartikelnummern an Channel Pilot Pro übertragen.
Beispielimplementierung des Bestellimports:
// Initialize ChannelPilotSellerApi
$api = new ChannelPilotSellerAPI_v1_0("cpMerchantId", "cpApiToken");
$run = true;
while($run){
// Request new marketplace orders from ChannelPilot
$response = $api->getNewMarketplaceOrders();
// Check if request was successful
if ($response->header->resultCode == CPResultCodes::SUCCESS) {
if (sizeof($response->orders) == 0) {
// No orders to import. Do nothing!
} else {
$run= (bool) $response->moreAvailable;
// Import orders into shopsystem and add internal ids for order and orderItems in orderObject
$orders = array();
foreach ($response->orders as $apiOrder) {
$orders[] = self::importOrder($apiOrder);
}
// Set marketplace orders successfully imported in ChannelPilot
$response= $api->setImportedOrders($orders, true);
// Check if request was successful
if ($response->header->resultCode == CPResultCodes::SUCCESS) {
foreach ($apiOrders as $apiOrder) {
if ($apiOrder->header->resultCode == CPResultCodes::SUCCESS) {
// Set the cpStatus for the orders in your database to '20' (imported)
self::changeOrderStatus($apiOrder->orderHeader);
} else {
// Error in your request data for this order
}
}
} else {
// Request getNewMarketplaceOrders had no success
}
}
}
}
API-Funktion- GETNEWMARKETPLACEORDERS()
$response = $api->getNewMarketplaceOrders();
Der Response der Funktion "getNewMarketplaceOrders()" enthält die Daten von maximal 10 Marktplatzbestellungen (orders) und einen Hinweis ob mehr Bestellungen verfügbar sind (moreAvailable = true/false).
Jede dieser Bestellungen ist ein "CPOrder-Objekt" aus der php-Library und ist ein Sammelcontainer für weitere Datenobjekte wie CPHeader, CPCustomer, CPAddress, CPPayment, CPShipping, …
Beispieldaten Response:
{
"moreAvailable": false,
"countMoreAvailable": 0,
"orders": [{
"orderHeader": {
"orderIdExternal": "TEST_ORDER_ID_MARKETPLACE",
"source": "marketplace_1",
"status": {
"identifier": "10",
"publicTitle": "Warten auf Export",
"publicDescription": "Die Bestellung wurde importiert und kann nun vom Shop abgeholt werden.",
"hasError": false
},
"orderTime": "2014-05-27T18:22:38+02:00"
},
"customer": {
"idExternal": "TEST_CUSTOMER_ID_IN_MARKETPLACE",
"genderId": 1,
"customerGroups": [{
"id": "0",
"title": "NOT LOGGED IN"
}],
"nameFirst": "Max",
"nameLast": "Mustermann",
"nameFull": "Max Mustermann",
"email": "maxmustermannsmail@testccvbnb.de",
"phone": "01234567890",
"mobile": "0160-55345234434345345",
"fax": "00492320023238237"
},
"addressInvoice": {
"genderId": 1,
"nameFirst": "Max",
"nameLast": "Mustermann",
"nameFull": "Max Mustermann",
"company": "MMC Ltd.",
"streetTitle": "Musterstr.",
"streetNumber": "1",
"streetFull": "Musterstr. 1",
"streetExtra": "c/o corporate llc",
"city": "Musterstadt",
"state": "Hamburg",
"zip": "12345",
"countryIso2": "DE",
"countryIso3": "DEU",
"phone": "01234567890"
},
"addressDelivery": {
"genderId": 1,
"nameFirst": "Max",
"nameLast": "Mustermann",
"nameFull": "Max Mustermann",
"company": "MMC Ltd.",
"streetTitle": "Musterstr.",
"streetNumber": "1",
"streetFull": "Musterstr. 1",
"streetExtra": "c/o corporate llc",
"city": "Musterstadt",
"state": "Sachsen",
"zip": "12345",
"countryIso2": "DE",
"countryIso3": "DEU",
"phone": "01234567890"
},
"itemsOrdered": [
{
"idExternal": "TEST_ITEM_ID_MARKETPLACE-1",
"article": {
"id": "GO-1003",
"idExternal": "TEST_ARTICLE_ID_MARKETPLACE_1",
"title": "Gorilla Espresso Bar Crema 1000g"
},
"quantityOrdered": 1,
"quantityDelivered": 0,
"quantityCancelled": 0,
"costsSingle": {
"net": 1.6807,
"gross": 2,
"tax": 0.3193,
"taxRate": 19
},
"costsTotal": {
"net": 1.6807,
"gross": 2,
"tax": 0.3193,
"taxRate": 19
},
"feeSingleNet": 0,
"feeTotalNet": 0
},
{
"idExternal": "TEST_ITEM_ID_MARKETPLACE-2",
"article": {
"id": "IL-3001",
"idExternal": "TEST_ARTICLE_ID_MARKETPLACE_2",
"title": "Illy Espresso Gemahlen N 250g"
},
"quantityOrdered": 2,
"quantityDelivered": 0,
"quantityCancelled": 0,
"costsSingle": {
"net": 1.4019,
"gross": 1.5,
"tax": 0.0982,
"taxRate": 7
},
"costsTotal": {
"net": 2.8037,
"gross": 3,
"tax": 0.1963,
"taxRate": 7
},
"feeSingleNet": 0,
"feeTotalNet": 0
}
],
"shipping": {
"typeId": "shippingType_1",
"typeTitle": "DHL Versand",
"costs": {
"net": 3.5499,
"gross": 4,
"tax": 0.4501,
"taxRate": 12.68
}
},
"payment": {
"typeId": "paymentType_1",
"typeTitle": "Nachnahme",
"costs": {
"net": 0,
"gross": 0,
"tax": 0,
"taxRate": 0
},
"paymentTime": "2014-05-27T18:22:38+02:00"
},
"summary": {
"totalSumItems": {
"net": 4.4844,
"gross": 5,
"tax": 0.5156,
"taxRate": 11.5
},
"totalSumOrder": {
"net": 8.0343,
"gross": 9,
"tax": 0.9657,
"taxRate": 12.02
},
"feeTotalNet": 0,
"currencyIso3": "EUR"
}
}],
"header": {
"resultCode": 200,
"resultMessage": ""
}
}
API-Funktion- SETIMPORTEDORDERS()
$result = $api->setImportedOrders($orders, true);
Um den erfolgreichen Import der Bestellungen an ChannelPilot zurückzumelden gibt es die Funktion "setImportedOrder()".
Hierbei werden die "CPOrder-Objekte" aus dem "getNewMarketplaceOrders"-Response um die orderId im orderHeader und die jeweilige id der itemsOrdered erweitert.
HINWEIS: Bei der id handelt es sich nicht um die Id des Shop Artikels sondern um die Id des Artikels in der Bestellung.
Beispieldaten Request:
[{
"orderHeader": {
"orderId":"TEST_ORDER_ID_SHOP",
"orderIdExternal": "TEST_ORDER_ID_MARKETPLACE",
"source": "marketplace_1",
"status": {
"identifier": "10",
"publicTitle": "Warten auf Export",
"publicDescription": "Die Bestellung wurde importiert und kann nun vom Shop abgeholt werden.",
"hasError": false
},
"orderTime": "2014-05-27T18:22:38+02:00"
},
"itemsOrdered": [{
"id":"TEST_ITEM_ID_SHOP-1",
"idExternal": "TEST_ITEM_ID_MARKETPLACE-1",
"article": {
"id": "GO-1003",
"idExternal": "TEST_ARTICLE_ID_MARKETPLACE_1",
"title": "Gorilla Espresso Bar Crema 1000g"
}
},
{
"id":"TEST_ITEM_ID_SHOP-1",
"idExternal": "TEST_ITEM_ID_MARKETPLACE-2",
"article": {
"id": "IL-3001",
"idExternal": "TEST_ARTICLE_ID_MARKETPLACE_2",
"title": "Illy Espresso Gemahlen N 250g"
}
}]
}]
Im Response befindet sich der neue status (20) der Bestellung oder eine Fehlermeldung.
Beispieldaten Response:
{
"updateResults":[{
"orderHeader":{
"orderId":"TEST_ORDER_ID_SHOP",
"orderIdExternal": "TEST_ORDER_ID_MARKETPLACE",
"source":"marketplace_1",
"status":{
"identifier":"20",
"publicTitle":"Importiert",
"publicDescription":"Die Bestellung wurde vom Shop importiert. Sie sollte nun versendet werden.",
"hasError":false
},
"orderTime":"2014-06-04T12:40:11+02:00"
},
"header":{
"resultCode":200,
"resultMessage":""
}
}],
"header":{
"resultCode":200,
"resultMessage":""
}
}
MARKTPLATZ CODES
Marktplatz | code |
alltricks (FRA) | alltricks_fra |
amazon (ARE) | amazon_are |
amazon (BEL) | amazon_bel |
amazon (CAN) | amazon_can |
amazon (DEU) | amazon.de |
amazon (EGY) | amazon_egy |
amazon (ESP) | amazon_esp |
amazon (FRA) | amazon_fra |
amazon (GBR) | amazon_gbr |
amazon (IND) | amazon_ind |
amazon (ITA) | amazon_ita |
amazon (JPN) | amazon_jpn |
amazon (MEX) | amazon_mex |
amazon (NLD) | amazon_nld |
amazon (POL) | amazon_pol |
amazon (SAU) | amazon_sau |
amazon (SWE) | amazon_swe |
amazon (TUR) | amazon_tur |
amazon (USA) | amazon_usa |
Bol.com (NLD) | bol.nl_nl |
Breuninger (DEU) | breuninger.de |
Bulevip (ESP) | bulevip_esp |
Carrefour (ESP) | carrefour_esp |
cdiscount (FRA) | cdiscount.fra |
CHECK24 Angebot (DEU) | check24.de |
conrad (DEU) | conrad_deu |
Decathlon (BEL) | decathlon_bel |
Decathlon (CZE) | decathlon_cze |
Decathlon (DEU) | decathlon_deu |
Decathlon (ESP) | decathlon_esp |
Decathlon (FRA) | decathlon_fra |
Decathlon (GBR) | decathlon_gbr |
Decathlon (HUN) | decathlon_hun |
Decathlon (ITA) | decathlon_ita |
Decathlon (NLD) | decathlon_nld |
Decathlon (PRT) | decathlon_prt |
Decathlon (ROU) | decathlon_rou |
Douglas (DEU) | douglas_deu |
ebay (AUS) | ebay_aus |
ebay (AUT) | ebay_aut |
ebay (CAN) | ebay_can |
ebay (CHE) | ebay_che |
ebay (DEU) | ebay.de |
ebay (ESP) | ebayes_esp |
ebay (FRA) | ebayfr_fra |
ebay (GBR) | ebaycouk_gbr |
ebay (HKG) | ebay_hkg |
ebay (IND) | ebay_ind |
ebay (IRL) | ebay_irl |
ebay (ITA) | ebayit_ita |
ebay (NLD) | ebay_nld |
ebay (PHL) | ebay_phl |
ebay (POL) | ebaypl_pol |
ebay (SGP) | ebay_sgp |
ebay (USA) | ebay_usa |
El Corte Ingles (ESP) | elcorteingles_esp |
Engelhorn (DEU) | engelhorn_deu |
fnac (ESP) | fnac_esp |
fnac (FRA) | fnac_fra |
fruugo (DEU) | fruugo_deu |
fruugo (ESP) | fruugo_esp |
fruugo (GBR) | fruugo_gbr |
Galaxus (CHE) | galaxus.ch |
Galaxus (DEU) | galaxus.de |
Goertz (DEU) | goertz.de |
Hornbach (DEU) | hornbach_deu |
kaufland.at (AUT) | kaufland_aut |
kaufland.cz Nabídka (CZE) | kaufland_cze |
kaufland.de Angebot (DEU) | real_deu |
kaufland.fr Angebot (FRA) | kaufland_fra |
kaufland.it Angebot (ITA) | kaufland_ita |
kaufland.pl (POL) | kaufland_pol |
kaufland.sk Ponuka (SVK) | kaufland_svk |
LaRedoute Mirakl (FRA) | laredoute_fr |
Leroy Merlin (FRA) | leroymerlin_fra |
Leroy Merlin (ITA) | leroymerlin_ita |
Leroy Merlin (PRT) | leroymerlin_prt |
Leroy Merlin (ESP) | leroymerlin_esp |
Limango (DEU) | limango_deu |
manomano (DEU) | manomano_deu |
manomano Pro (DEU) | manomanopro_deu |
manomano (ESP) | manomano_esp |
manomano (FRA) | manomano_fra |
manomano (GBR) | manomano_gbr |
manomano (ITA) | manomano_ita |
MAPI amazon (DEU) | amazon.deu |
MAPI amazon (FRA) | amazon.fra |
MAPI amazon (ITA) | amazon.ita |
MAPI amazon (GBR) | amazon.gbr |
MAPI amazon (ESP) | amazon.esp |
MAPI amazon (CAN) | amazon.can |
MAPI amazon (USA) | amazon.usa |
MAPI amazon (MEX) | amazon.mex |
MAPI amazon (IND) | amazon.ind |
MAPI amazon (JPN) | amazon.jpn |
MAPI amazon (ARE) | amazon.are |
MAPI amazon (AUS) | amazon.aus |
MAPI amazon (NLD) | amazon.nld |
MAPI amazon (TUR) | amazon.tur |
MAPI amazon (SAU) | amazon.sau |
MAPI amazon (SWE) | amazon.swe |
MAPI amazon (AUT) | amazon.aut |
MAPI amazon (POL) | amazon.pol |
MAPI amazon (BEL) | amazon.bel |
Marktkauf (DEU) | marktkauf_de |
MediaMarkt/Saturn (AUT) | mediamarktsaturn_aut |
MediaMarkt/Saturn (BEL) | mediamarktsaturn_bel |
MediaMarkt/Saturn (DEU) | mediamarktsaturn_deu |
MediaMarkt/Saturn (ESP) | mediamarktsaturn_esp |
MediaMarkt/Saturn (NLD) | mediamarktsaturn_nld |
Miravia (ESP) | miravia_esp |
Netto (DEU) | netto_de |
OnBuy (GBR) | OnBuy.com |
Otto Market (DEU) | otto.de |
PC-Componentes (ESP) | pccomponentes_esp |
Rakuten (FRA) | rakuten.fr |
Shop Apotheke (AUT) | shopapotheke_aut |
Shop Apotheke (DEU) | shopapotheke_deu |
Shöpping (AUT) | shoepping_at |
Tradeinn (ESP) | tradeinn_esp |
Trendyol (DEU) | trendyol_com |
Voelkner (DEU) | voelkner_deu |
Zalando (AUT) | zalando.at |
Zalando (BEL) | zalando.be |
Zalando (CHE) | zalando.ch |
Zalando (CZE) | zalando.cz |
Zalando (DEU) | zalando.de |
Zalando (DNK) | zalando.dk |
Zalando (ESP) | zalando.es |
Zalando (FIN) | zalando.fi |
Zalando (FRA) | zalando.fr |
Zalando (IRL) | zalando.ie |
Zalando (ITA) | zalando.it |
Zalando (NLD) | zalando.nl |
Zalando (NOR) | zalando.no |
Zalando (POL) | zalando.pl |
Zalando (PRT) | zalando.pt |
Zalando (SWE) | zalando.se |
