0

I have around 8000 customers to import via the API. It works like a dream besides from its really slow. Is there any ways in which I can speed it up?

1

The core methods for import are historically rather slow. I would reccomend that you consider using an alternative API Import script such as this one created by Daniel Sloof. https://github.com/danslo/ApiImport

You would parse your customers into a compatible array, then fire it into the API import call.

$batch = array(); // Prepare customer records here.
$proc['api'] = Mage::getModel('api_import/import_api');
$proc['api']->importEntities(
                        $batch,
                        Mage_ImportExport_Model_Import_Entity_Customer::getEntityTypeCode(),
                        Mage_ImportExport_Model_Import::BEHAVIOR_REPLACE
                    );

We used this method on a recent project and were able to successfully import in the region of 0.5 Million customers in about 1h.

Example from our parsing of our source file for a customer record - note that shipping address and billing address go in as two seperate rows so first row is the main customer record, then its the address. Then moves onto the next customer.

$d = array(
                    '_website' => $setup['arg_webcode'],
                    'group_id' => 9,
                    'email' => $_customer['users_usrEmail'],
                    'disable_auto_group_change' => 1,
                    'firstname' => $_customer['users_usrBillToFirstName'],
                    'lastname' => $_customer['users_usrBillToLastName'],
                    'password' => $_customer['users_usrPassword'],
                    'taxvat' => $_customer['users_usrVATNumber'],
                    'reward_update_notification' => 0,
                    'reward_warning_notification' => 0,
                    'created_in' => 'default',
                    'created_at' => $_customer['users_usrRegisterDate'],
                    'is_subscribed' => 0,
                    'group' => 'General',
                    'archive_user_id' => $_customer['users_usrID'],
                    '_address_firstname' => $_customer['users_usrBillToFirstName'],
                    '_address_lastname' => $_customer['users_usrBillToLastName'],
                    '_address_street' => trim($_customer['users_usrBillToAddress1'] . ' ' . $_customer['users_usrBillToAddress2'] . ' ' . $_customer['users_usrBillToAddress3']),
                    '_address_street1' => $_customer['users_usrBillToAddress1'],
                    '_address_street2' => $_customer['users_usrBillToAddress2'],
                    '_address_street3' => $_customer['users_usrBillToAddress3'],
                    '_address_city' => $_customer['users_usrBillToCity'],
                    '_address_region' => $_customer['users_usrBillToState'],
                    '_address_country_id' => $_customer['users_usrBillToCountry'],
                    '_address_postcode' => $_customer['users_usrBillToZip'],
                    '_address_telephone' => $_customer['users_usrBillToPhone1'],
                    '_address_company' => $_customer['users_usrBillToCompany'],
                    '_address_default_billing_' => 1,
                    '_credits' => $_customer['users_uscAmmount']
                );
                // CUSTOMER & BILLING ADDRESS DATA

                // ADD CUSTOMERS SHIPPING DATA IF DIFFERANT FROM BILLING ADDRESS
                if ($_incShipping === true) {
                    $s = array(
                        '_website' => null,
                        'email' => null,
                        'group_id' => 9,
                        'firstname' => $_customer['users_usrBillToFirstName'],
                        'lastname' => $_customer['users_usrBillToLastName'],
                        'reward_update_notification' => 0,
                        'reward_warning_notification' => 0,
                        '_address_firstname' => $_customer['users_usrShipToFirstName'],
                        '_address_lastname' => $_customer['users_usrShipToLastName'],
                        '_address_street' => trim($_customer['users_usrShipToAddress1'] . ' ' . $_customer['users_usrShipToAddress2'] . ' ' . $_customer['users_usrShipToAddress3']),
                        '_address_street1' => $_customer['users_usrShipToAddress1'],
                        '_address_street2' => $_customer['users_usrShipToAddress2'],
                        '_address_street3' => $_customer['users_usrShipToAddress3'],
                        '_address_city' => $_customer['users_usrShipToCity'],
                        '_address_region' => $_customer['users_usrShipToState'],
                        '_address_country_id' => $_customer['users_usrShipToCountry'],
                        '_address_postcode' => $_customer['users_usrShipToZip'],
                        '_address_telephone' => $_customer['users_usrShipToPhone1'],
                        '_address_company' => $_customer['users_usrShipToCompany'],
                        '_address_default_shipping_' => 1
                    );
                } else {
                    $d['_address_default_shipping_'] = 1;
                }
  • Looks exactly like what I was after however I cant initially see how the structure of the array should look like. Could you advise – Goose84 Jan 15 '16 at 15:40
  • @Goose84 I've updated with an example from what we were doing. Depending on your needs some of the feilds could potentially be dropped from being imported eg _address if you dont have address information. – John Cuthbert Jan 15 '16 at 15:47
  • Thanks, the only issue now I am getting Fatal error: Call to a member function importEntities() on a non-object. It seems as though its not getting than model as Mage::getModel("customer/customer"); works fine – Goose84 Jan 15 '16 at 16:00
  • importEntitites should be called on this: Mage::getModel('api_import/import_api'); It should be there if you've included the above linked module. – John Cuthbert Jan 15 '16 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.