diff --git a/admin-dev/themes/default/template/controllers/import/helpers/form/form.tpl b/admin-dev/themes/default/template/controllers/import/helpers/form/form.tpl index dd625abea..a9706516a 100644 --- a/admin-dev/themes/default/template/controllers/import/helpers/form/form.tpl +++ b/admin-dev/themes/default/template/controllers/import/helpers/form/form.tpl @@ -122,7 +122,7 @@
{l s='Import'} - +
{if count($files_to_import)}
- +
+ +
+ {l s='If you don\'t use this option, all IDs will be auto-incremented.'} +
{if empty($files_to_import)}{l s='You must upload a file for go to the next step.'}{/if} @@ -255,6 +259,11 @@ else $(".import_products_categories").hide(); + if ($("#entity > option:selected").val() == 0 || $("#entity > option:selected").val() == 1 || $("#entity > option:selected").val() == 3) + $("label[for=forceIDs],#forceIDs").show(); + else + $("label[for=forceIDs],#forceIDs").hide(); + $("#entitie").html($("#entity > option:selected").text().toLowerCase()); $.ajax({ url: 'ajax.php', diff --git a/admin-dev/themes/default/template/controllers/import/helpers/view/view.tpl b/admin-dev/themes/default/template/controllers/import/helpers/view/view.tpl index 6e12aa6de..fa655d9a8 100644 --- a/admin-dev/themes/default/template/controllers/import/helpers/view/view.tpl +++ b/admin-dev/themes/default/template/controllers/import/helpers/view/view.tpl @@ -67,6 +67,9 @@ {if $fields_value.truncate} {/if} + {if $fields_value.forceIDs} + + {/if} {if $fields_value.match_ref} {/if} diff --git a/classes/ObjectModel.php b/classes/ObjectModel.php index afeec34ac..f64438f7e 100644 --- a/classes/ObjectModel.php +++ b/classes/ObjectModel.php @@ -458,7 +458,7 @@ abstract class ObjectModelCore } // Database insertion - if (isset($this->id)) + if (isset($this->id) && !Tools::getValue('forceIDs')) unset($this->id); if (Shop::checkIdShopDefault($this->def['table'])) $this->id_shop_default = min($id_shop_list); diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index 2fc30d6b0..f7654de48 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -504,6 +504,7 @@ class AdminImportControllerCore extends AdminController 'entity' => (int)Tools::getValue('entity'), 'iso_lang' => Tools::getValue('iso_lang'), 'truncate' => Tools::getValue('truncate'), + 'forceIDs' => Tools::getValue('forceIDs'), 'match_ref' => Tools::getValue('match_ref'), 'separator' => $this->separator, 'multiple_value_separator' => $this->multiple_value_separator @@ -728,7 +729,7 @@ class AdminImportControllerCore extends AdminController foreach (self::$column_mask as $type => $nb) $res[$type] = isset($row[$nb]) ? $row[$nb] : null; - if (Tools::getValue('truncate')) //if you choose to truncate table before import the column id is remove from the CSV file. + if (Tools::getValue('forceIds')) // if you choose to force table before import the column id is remove from the CSV file. unset($res['id']); return $res; @@ -850,7 +851,12 @@ class AdminImportControllerCore extends AdminController continue; } AdminImportController::setDefaultValues($info); - $category = new Category(); + + if (Tools::getValue('forceIDs') && isset($info['id']) && (int)$info['id']) + $category = new Category((int)$info['id']); + else + $category = new Category(); + AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $category); if (isset($category->parent) && is_numeric($category->parent)) @@ -863,7 +869,10 @@ class AdminImportControllerCore extends AdminController { $category_parent = Category::searchByName($default_language_id, $category->parent, true); if ($category_parent['id_category']) + { $category->id_parent = (int)$category_parent['id_category']; + $category->level_depth = (int)$category_parent['level_depth'] + 1; + } else { $category_to_create = new Category(); @@ -1006,16 +1015,19 @@ class AdminImportControllerCore extends AdminController if (Tools::getValue('convert')) $line = $this->utf8EncodeArray($line); $info = AdminImportController::getMaskedRow($line); + + if (Tools::getValue('forceIDs') && isset($info['id']) && (int)$info['id']) + $product = new Product((int)$info['id']); + else + $product = new Product(); + if (array_key_exists('id', $info) && (int)$info['id'] && Product::existsInDatabase((int)$info['id'], 'product')) { - $product = new Product((int)$info['id']); $product->loadStockData(); $category_data = Product::getProductCategories((int)$product->id); foreach ($category_data as $tmp) $product->category[] = $tmp; } - else - $product = new Product(); AdminImportController::setEntityDefaultValues($product); AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $product); diff --git a/css/admin.css b/css/admin.css index d514a7c69..2b606208e 100644 --- a/css/admin.css +++ b/css/admin.css @@ -228,7 +228,7 @@ label { font-weight:bold; padding:0.2em 0 0; text-align:left; - width:300px; + width:320px; } label.t { diff --git a/translations/fr/admin.php b/translations/fr/admin.php index 3f6a22f35..671d74024 100644 --- a/translations/fr/admin.php +++ b/translations/fr/admin.php @@ -1321,6 +1321,7 @@ $_LANGADM['AdminImport2415390fb5052bb8221a93c9fc51b17f'] = 'Importer les donnée $_LANGADM['AdminImport2688a544cd5ac33f27ab78c8d8c3acaa'] = 'Nom *'; $_LANGADM['AdminImport278c491bdd8a53618c149c4ac790da34'] = 'Modèle'; $_LANGADM['AdminImport284b47b0bb63ae2df3b29f0e691d6fcf'] = 'Adresses'; +$_LANGADM['AdminImport28bc6f0862918aba3c4b3e80212a3fc5'] = 'Forcer tous les identifiants lors de l\'importation?'; $_LANGADM['AdminImport2a08996307b8694521492f3ca7b5df40'] = 'Exemple de fichier de déclinaisons'; $_LANGADM['AdminImport2a1a026f56b4c51cc839e513370379fd'] = 'Langue du fichier :'; $_LANGADM['AdminImport2a982c2c140ad66259355df1e2c5b69f'] = 'Méta description'; @@ -1363,6 +1364,7 @@ $_LANGADM['AdminImport6afcfa28445fa35c1f6618a471891ed8'] = 'La commande fourniss $_LANGADM['AdminImport6c7c9fbb27699c4018dc15744547b4a4'] = 'Catégorie racine (0/1)'; $_LANGADM['AdminImport6d5030fd40c1e08767b4b70d3786b0fb'] = 'L\'ID du fournisseur (%d) n\'est pas valable(ligne %d).'; $_LANGADM['AdminImport70e7a6fcceb39a1e3ea3925182b85d18'] = 'AAAA-MM-JJ'; +$_LANGADM['AdminImport72412dc8aa8825cd4f72b4fd1c0b05a2'] = 'Si vous n\'utilisez pas cette option, tous les identifiants seront générés via l\'auto-incrémentation.'; $_LANGADM['AdminImport72d6d7a1885885bb55a565fd1070581a'] = 'Import'; $_LANGADM['AdminImport72ef2b9b6965d078e3c7f95487a82d1c'] = 'Sauter'; $_LANGADM['AdminImport76aeea9f48196068e6b47d46d41e7618'] = 'Afficher le prix (0 = Non, 1 = Oui)';