API-Import - Kunden importieren

Hallo, habe über den API-Import Hersteller, Kategorien, Artikel importiert (Testumgebung). Das funktioniert einwandfrei und das API ist leicht zu bedienen. Jetzt bin ich dabei Kunden zu importieren, bloß hier hakts. Eigentlich sollte doch nur die E-Mail-Adresse Pflichtfeld sein. Ich habe alle Daten in einem Array angegeben und trotzdem wird der Kunde nicht importiert. [code] function importCustomers() { global $api; global $import; $sql = getCustomerSelect(); $dbResCustomer = mysql_query($sql) or die(mysql_error()); while ($curRow = mysql_fetch_array($dbResCustomer)) { $countryID = $api->sDB->GetOne(“select id from s_core_countries where countryiso = '” . $curRow[‘billing_countryiso’] . “’”); $customer = array( ‘email’ => $curRow[‘email’], ‘md5_password’ => $curRow[‘md5_password’], ‘accountmode’ => $curRow[‘accountmode’], ‘customernumber’ => $curRow[‘customernumber’], ‘birthday’ => $curRow[‘birthday’], ‘billing_company’ => $curRow[‘billing_company’], ‘billing_salutation’ => $curRow[‘billing_salutation’], ‘billing_firstname’ => $curRow[‘billing_firstname’], ‘billing_lastname’ => $curRow[‘billing_lastname’], ‘billing_street’ => splitStreetAndNumber($curRow[‘billing_street’], ‘street’), ‘billing_streetnumber’ => splitStreetAndNumber($curRow[‘billing_street’], ‘number’), ‘billing_zipcode’ => $curRow[‘billing_zipcode’], ‘billing_city’ => $curRow[‘billing_city’], ‘billing_countryID’ => $countryID, ‘phone’ => $curRow[‘phone’], ‘fax’ => $curRow[‘fax’], ‘ustid’ => $curRow[‘ustid’], ‘shipping_company’ => $curRow[‘shipping_company’], ‘shipping_salutation’ => $curRow[‘shipping_salutation’], ‘shipping_firstname’ => $curRow[‘shipping_firstname’], ‘shipping_lastname’ => $curRow[‘shipping_lastname’], ‘shipping_street’ => splitStreetAndNumber($curRow[‘shipping_street’], ‘street’), ‘shipping_streetnumber’ => splitStreetAndNumber($curRow[‘shipping_street’], ‘number’), ‘shipping_zipcode’ => $curRow[‘shipping_zipcode’], ‘shipping_city’ => $curRow[‘shipping_city’], ‘shipping_countryID’ => $countryID ); /* echo ’

'; var\_dump($customer); echo '

'; */ $curCustomer = $import->sCustomer($customer); setIdMapping(I_TYPE_CUSTOMER, $curRow[‘customerID’], $curCustomer[‘userID’]); } } } [/code]

Die SQL-Anweisung hab ich vom Import-Tool übernommen und leicht angepasst. :wink: function getCustomerSelect() { return " SELECT u.customers\_id as customerID, u.customers\_id as customernumber, u.account\_type as accountmode, IF(a.entry\_gender IN ('m', 'Herr'), 'mr', 'ms') as billing\_salutation, a.entry\_firstname as billing\_firstname, a.entry\_lastname as billing\_lastname, a.entry\_company as billing\_company, '' as billing\_department, a.entry\_street\_address as billing\_street, '' as billing\_streetnumber, a.entry\_postcode as billing\_zipcode, a.entry\_city as billing\_city, c.countries\_iso\_code\_2 as billing\_countryiso, IF(a.entry\_gender IN ('m', 'Herr'), 'mr', 'ms') as shipping\_salutation, a.entry\_firstname as shipping\_firstname, a.entry\_lastname as shipping\_lastname, a.entry\_company as shipping\_company, '' as shipping\_department, a.entry\_street\_address as shipping\_street, '' as shipping\_streetnumber, a.entry\_postcode as shipping\_zipcode, a.entry\_city as shipping\_city, c.countries\_iso\_code\_2 as shipping\_countryiso, u.customers\_telephone as phone, u.customers\_fax as fax, u.customers\_email\_address as email, u.customers\_dob as birthday, u.customers\_vat\_id as ustid, u.customers\_newsletter as newsletter, u.customers\_password as md5\_password, u.customers\_status as customergroupID, u.customers\_date\_added as firstlogin, IF(u.delete\_user=1, 0, 1) as active FROM customers u JOIN address\_book a ON a.customers\_id=u.customers\_id AND a.address\_book\_id=u.customers\_default\_address\_id LEFT JOIN countries c ON c.countries\_id=a.entry\_country\_id WHERE u.customers\_id \< 10; "; }

Gibt’s denn eine Möglichkeit rauszukriegen, wo das Problem liegt - Fehlermeldung? Kann doch nicht so schwierig sein. :wink:

Hey, da würde ich direkt in der connectors/api/import/shopware.php - Funktion sCustomer mal einen Breakpoint setzen bzw. den SQL-Code ausgeben lassen. Also einfach jeweils vor: $result = $this-\>sDB-\>Execute($sql); die($sql); ausführen. Dann die Queries manuell in PHPMyAdmin ausführen und prüfen wo er aussteigt. Da wird wahrscheinlich irgendwo ein SQL-Fehler auftreten und da schweigt sich der API-Import im Moment noch aus.

OK, Danke. Wird gemacht.

Hallo, hab folgenden Code in der ‘connectors/api/import/shopware.php’, Methode ‘sCustomer’, Zeile 907 gefunden. Denke, es müsste ‘$customer[‘shippingaddressID’]’ statt ‘$article[‘shippingaddressID’]’ heißen. if(!empty($upset)&&count($upset)\>1) { $upset = implode(", ",$upset); $sql = " UPDATE s\_user\_shippingaddress SET $upset WHERE id = {$article['shippingaddressID']} ";

Danke für die Info - das stimmt soweit und wird korrigiert. Funktioniert es dann jetzt bei dir?

Ja, das Updaten von Kunden funktioniert dann. Das war das Problem.