diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index bba5c5cde..2fc30d6b0 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -308,6 +308,7 @@ class AdminImportControllerCore extends AdminController 'alias' => array('label' => $this->l('Alias *')), 'active' => array('label' => $this->l('Active (0/1)')), 'customer_email' => array('label' => $this->l('Customer e-mail')), + 'id_customer' => array('label' => $this->l('Customer ID')), 'manufacturer' => array('label' => $this->l('Manufacturer')), 'supplier' => array('label' => $this->l('Supplier')), 'company' => array('label' => $this->l('Company')), @@ -1972,6 +1973,31 @@ class AdminImportControllerCore extends AdminController continue; } } + elseif (isset($address->id_customer) && !empty($address->id_customer)) + { + if (Customer::customerIdExistsStatic((int)$address->id_customer)) + { + $customer = new Customer((int)$address->id_customer); + + // a customer could exists in different shop + $customer_list = Customer::getCustomersByEmail($customer->email); + + if (count($customer_list) == 0) + $this->errors[] = sprintf( + Tools::displayError('%1$s does not exist in database %2$s (ID: %3$s) cannot be saved'), + Db::getInstance()->getMsgError(), + $customer->email, + (int)$address->customer_id + ); + } + else + $this->errors[] = sprintf(Tools::displayError('The customer ID n.%d does not exist in database (ID: %d) cannot be saved'), $address->customer_id); + } + else + { + $customer_list = array(); + $address->id_customer = 0; + } if (isset($address->manufacturer) && is_numeric($address->manufacturer) && Manufacturer::manufacturerExists((int)$address->manufacturer)) $address->id_manufacturer = (int)$address->manufacturer; diff --git a/docs/csv_import/addresses_import.csv b/docs/csv_import/addresses_import.csv index dce9b0a27..2ba8be1ca 100644 --- a/docs/csv_import/addresses_import.csv +++ b/docs/csv_import/addresses_import.csv @@ -1,4 +1,4 @@ -id;Alias*;Active (0/1);Customer e-mail;Manufacturer;Supplier;Company;Lastname*;Firstname*;Address 1*;Address 2;Postcode* / Zipcode*;City*;Country*;State;Other;Phone;Mobile Phone;VAT number -1;My Adress;1;johndoe@prestashop.com;;;;Doe;John;16, Main street;2nd floor;75000;PARIS ;France;;;140138844;; -2;My work;1;johndoe@prestashop.com;;;My Company;Doe;John;535, Baker street;;13000;Marseile;France;;;235445588;; -3;My work;0;;Apple Computer, Inc;;;Jobs;Steve;1 Infinite Loop;;95014;CUPERTINO;United States;California;;(800) 275-2273;; \ No newline at end of file +"id";"Alias*";"Active (0/1)";"Customer e-mail";"Customer ID";"Manufacturer";"Supplier";"Company";"Lastname*";"Firstname*";"Address 1*";"Address 2";"Postcode* / Zipcode*";"City*";"Country*";"State";"Other";"Phone";"Mobile Phone";"VAT number" +1;"My Adress";1;"pub@prestashop.com";1;;;;"Doe";"John";"16, Main street";"2nd floor";75000;"PARIS ";"France";;;140138844;; +2;"My work";1;"pub@prestashop.com";1;;;"My Company";"Doe";"John";"535, Baker street";;13000;"Marseile";"France";;;235445588;; +3;"My work";0;;;"Apple Computer, Inc";;;"Jobs";"Steve";"1 Infinite Loop";;95014;"CUPERTINO";"United States";"California";;"(800) 275-2273";; diff --git a/translations/fr/admin.php b/translations/fr/admin.php index 9041f23d1..3f6a22f35 100644 --- a/translations/fr/admin.php +++ b/translations/fr/admin.php @@ -1432,6 +1432,7 @@ $_LANGADM['AdminImportca676c9ec4e1ae9fe9df3ac28910e6ef'] = 'Le prix unitaire HT $_LANGADM['AdminImportcbfb910715c99134a5987630fff104da'] = 'Exemple de fichier de catégories'; $_LANGADM['AdminImportcf7a1f189bbd1f48db0ece1da9cc0802'] = 'Disponible à la commande (0 = Non, 1 = Oui)'; $_LANGADM['AdminImportd1457b72c3fb323a2671125aef3eab5d'] = '?'; +$_LANGADM['AdminImportd37c2bf1bd3143847fca087b354f920e'] = 'ID du client'; $_LANGADM['AdminImportd66424c2034991e541dee7face1851fc'] = 'Fichier encodé en ISO-8859-1 ?'; $_LANGADM['AdminImportd7a158f13040edafc30b622d16c8b12d'] = '* Champs requis'; $_LANGADM['AdminImportd7fa0b529a16e87f34d8ef35054c765c'] = 'Importer des produits dans une commande fournisseur va d\'abord effacer les produits contenus dans cette commande.';