[-] BO : fix #PSCFV-4596 : added an option for to force the id during CSV import
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@17684 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -122,7 +122,7 @@
|
|||||||
<fieldset style="float: left; margin: 0pt 20px 0pt 0pt; width: 70%;">
|
<fieldset style="float: left; margin: 0pt 20px 0pt 0pt; width: 70%;">
|
||||||
<legend><img src="../img/admin/import.gif" />{l s='Import'}</legend>
|
<legend><img src="../img/admin/import.gif" />{l s='Import'}</legend>
|
||||||
|
|
||||||
<label class="clear">{if count($files_to_import) > 1}{l s='Your CSV file (%d files):' sprintf=files_to_import}{else}{l s='Your CSV file (%d file):' sprintf=files_to_import}{/if}</label>
|
<label class="clear">{if count($files_to_import) > 1}{l s='Your CSV file (%d files):' sprintf=count($files_to_import)}{else}{l s='Your CSV file (%d file):' sprintf=count($files_to_import)}{/if}</label>
|
||||||
<div class="margin-form">
|
<div class="margin-form">
|
||||||
{if count($files_to_import)}
|
{if count($files_to_import)}
|
||||||
<select name="csv">
|
<select name="csv">
|
||||||
@@ -173,10 +173,14 @@
|
|||||||
<div class="margin-form">
|
<div class="margin-form">
|
||||||
<input name="truncate" id="truncate" type="checkbox"/>
|
<input name="truncate" id="truncate" type="checkbox"/>
|
||||||
</div>
|
</div>
|
||||||
<label for="match_ref" class="clear" style="display: none">{l s='Use product reference as key?'}</label>
|
<label for="match_ref" class="clear" style="display: none">{l s='Use product reference as key?'}</label>
|
||||||
<div class="margin-form">
|
<div class="margin-form">
|
||||||
<input name="match_ref" id="match_ref" type="checkbox" style="margin-top: 6px; display:none"/>
|
<input name="match_ref" id="match_ref" type="checkbox" style="margin-top: 6px; display:none"/>
|
||||||
</div>
|
</div>
|
||||||
|
<label for="forceIDs" class="clear">{l s='Force all ids during import?'} </label>
|
||||||
|
<div class="margin-form">
|
||||||
|
<input name="forceIDs" id="forceIDs" type="checkbox"/> {l s='If you don\'t use this option, all IDs will be auto-incremented.'}
|
||||||
|
</div>
|
||||||
<div class="space margin-form">
|
<div class="space margin-form">
|
||||||
<input type="submit" name="submitImportFile" value="{l s='Next step'}" class="button" {if empty($files_to_import)}disabled{/if}/>
|
<input type="submit" name="submitImportFile" value="{l s='Next step'}" class="button" {if empty($files_to_import)}disabled{/if}/>
|
||||||
{if empty($files_to_import)}<span style="color:red;">{l s='You must upload a file for go to the next step.'}</span>{/if}
|
{if empty($files_to_import)}<span style="color:red;">{l s='You must upload a file for go to the next step.'}</span>{/if}
|
||||||
@@ -255,6 +259,11 @@
|
|||||||
else
|
else
|
||||||
$(".import_products_categories").hide();
|
$(".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());
|
$("#entitie").html($("#entity > option:selected").text().toLowerCase());
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'ajax.php',
|
url: 'ajax.php',
|
||||||
|
|||||||
@@ -67,6 +67,9 @@
|
|||||||
{if $fields_value.truncate}
|
{if $fields_value.truncate}
|
||||||
<input type="hidden" name="truncate" value="1" />
|
<input type="hidden" name="truncate" value="1" />
|
||||||
{/if}
|
{/if}
|
||||||
|
{if $fields_value.forceIDs}
|
||||||
|
<input type="hidden" name="forceIDs" value="1" />
|
||||||
|
{/if}
|
||||||
{if $fields_value.match_ref}
|
{if $fields_value.match_ref}
|
||||||
<input type="hidden" name="match_ref" value="1" />
|
<input type="hidden" name="match_ref" value="1" />
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -458,7 +458,7 @@ abstract class ObjectModelCore
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Database insertion
|
// Database insertion
|
||||||
if (isset($this->id))
|
if (isset($this->id) && !Tools::getValue('forceIDs'))
|
||||||
unset($this->id);
|
unset($this->id);
|
||||||
if (Shop::checkIdShopDefault($this->def['table']))
|
if (Shop::checkIdShopDefault($this->def['table']))
|
||||||
$this->id_shop_default = min($id_shop_list);
|
$this->id_shop_default = min($id_shop_list);
|
||||||
|
|||||||
@@ -504,6 +504,7 @@ class AdminImportControllerCore extends AdminController
|
|||||||
'entity' => (int)Tools::getValue('entity'),
|
'entity' => (int)Tools::getValue('entity'),
|
||||||
'iso_lang' => Tools::getValue('iso_lang'),
|
'iso_lang' => Tools::getValue('iso_lang'),
|
||||||
'truncate' => Tools::getValue('truncate'),
|
'truncate' => Tools::getValue('truncate'),
|
||||||
|
'forceIDs' => Tools::getValue('forceIDs'),
|
||||||
'match_ref' => Tools::getValue('match_ref'),
|
'match_ref' => Tools::getValue('match_ref'),
|
||||||
'separator' => $this->separator,
|
'separator' => $this->separator,
|
||||||
'multiple_value_separator' => $this->multiple_value_separator
|
'multiple_value_separator' => $this->multiple_value_separator
|
||||||
@@ -728,7 +729,7 @@ class AdminImportControllerCore extends AdminController
|
|||||||
foreach (self::$column_mask as $type => $nb)
|
foreach (self::$column_mask as $type => $nb)
|
||||||
$res[$type] = isset($row[$nb]) ? $row[$nb] : null;
|
$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']);
|
unset($res['id']);
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
@@ -850,7 +851,12 @@ class AdminImportControllerCore extends AdminController
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
AdminImportController::setDefaultValues($info);
|
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);
|
AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $category);
|
||||||
|
|
||||||
if (isset($category->parent) && is_numeric($category->parent))
|
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);
|
$category_parent = Category::searchByName($default_language_id, $category->parent, true);
|
||||||
if ($category_parent['id_category'])
|
if ($category_parent['id_category'])
|
||||||
|
{
|
||||||
$category->id_parent = (int)$category_parent['id_category'];
|
$category->id_parent = (int)$category_parent['id_category'];
|
||||||
|
$category->level_depth = (int)$category_parent['level_depth'] + 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$category_to_create = new Category();
|
$category_to_create = new Category();
|
||||||
@@ -1006,16 +1015,19 @@ class AdminImportControllerCore extends AdminController
|
|||||||
if (Tools::getValue('convert'))
|
if (Tools::getValue('convert'))
|
||||||
$line = $this->utf8EncodeArray($line);
|
$line = $this->utf8EncodeArray($line);
|
||||||
$info = AdminImportController::getMaskedRow($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'))
|
if (array_key_exists('id', $info) && (int)$info['id'] && Product::existsInDatabase((int)$info['id'], 'product'))
|
||||||
{
|
{
|
||||||
$product = new Product((int)$info['id']);
|
|
||||||
$product->loadStockData();
|
$product->loadStockData();
|
||||||
$category_data = Product::getProductCategories((int)$product->id);
|
$category_data = Product::getProductCategories((int)$product->id);
|
||||||
foreach ($category_data as $tmp)
|
foreach ($category_data as $tmp)
|
||||||
$product->category[] = $tmp;
|
$product->category[] = $tmp;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
$product = new Product();
|
|
||||||
|
|
||||||
AdminImportController::setEntityDefaultValues($product);
|
AdminImportController::setEntityDefaultValues($product);
|
||||||
AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $product);
|
AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $product);
|
||||||
|
|||||||
+1
-1
@@ -228,7 +228,7 @@ label {
|
|||||||
font-weight:bold;
|
font-weight:bold;
|
||||||
padding:0.2em 0 0;
|
padding:0.2em 0 0;
|
||||||
text-align:left;
|
text-align:left;
|
||||||
width:300px;
|
width:320px;
|
||||||
}
|
}
|
||||||
|
|
||||||
label.t {
|
label.t {
|
||||||
|
|||||||
@@ -1321,6 +1321,7 @@ $_LANGADM['AdminImport2415390fb5052bb8221a93c9fc51b17f'] = 'Importer les donnée
|
|||||||
$_LANGADM['AdminImport2688a544cd5ac33f27ab78c8d8c3acaa'] = 'Nom *';
|
$_LANGADM['AdminImport2688a544cd5ac33f27ab78c8d8c3acaa'] = 'Nom *';
|
||||||
$_LANGADM['AdminImport278c491bdd8a53618c149c4ac790da34'] = 'Modèle';
|
$_LANGADM['AdminImport278c491bdd8a53618c149c4ac790da34'] = 'Modèle';
|
||||||
$_LANGADM['AdminImport284b47b0bb63ae2df3b29f0e691d6fcf'] = 'Adresses';
|
$_LANGADM['AdminImport284b47b0bb63ae2df3b29f0e691d6fcf'] = 'Adresses';
|
||||||
|
$_LANGADM['AdminImport28bc6f0862918aba3c4b3e80212a3fc5'] = 'Forcer tous les identifiants lors de l\'importation?';
|
||||||
$_LANGADM['AdminImport2a08996307b8694521492f3ca7b5df40'] = 'Exemple de fichier de déclinaisons';
|
$_LANGADM['AdminImport2a08996307b8694521492f3ca7b5df40'] = 'Exemple de fichier de déclinaisons';
|
||||||
$_LANGADM['AdminImport2a1a026f56b4c51cc839e513370379fd'] = 'Langue du fichier :';
|
$_LANGADM['AdminImport2a1a026f56b4c51cc839e513370379fd'] = 'Langue du fichier :';
|
||||||
$_LANGADM['AdminImport2a982c2c140ad66259355df1e2c5b69f'] = 'Méta description';
|
$_LANGADM['AdminImport2a982c2c140ad66259355df1e2c5b69f'] = 'Méta description';
|
||||||
@@ -1363,6 +1364,7 @@ $_LANGADM['AdminImport6afcfa28445fa35c1f6618a471891ed8'] = 'La commande fourniss
|
|||||||
$_LANGADM['AdminImport6c7c9fbb27699c4018dc15744547b4a4'] = 'Catégorie racine (0/1)';
|
$_LANGADM['AdminImport6c7c9fbb27699c4018dc15744547b4a4'] = 'Catégorie racine (0/1)';
|
||||||
$_LANGADM['AdminImport6d5030fd40c1e08767b4b70d3786b0fb'] = 'L\'ID du fournisseur (%d) n\'est pas valable(ligne %d).';
|
$_LANGADM['AdminImport6d5030fd40c1e08767b4b70d3786b0fb'] = 'L\'ID du fournisseur (%d) n\'est pas valable(ligne %d).';
|
||||||
$_LANGADM['AdminImport70e7a6fcceb39a1e3ea3925182b85d18'] = 'AAAA-MM-JJ';
|
$_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['AdminImport72d6d7a1885885bb55a565fd1070581a'] = 'Import';
|
||||||
$_LANGADM['AdminImport72ef2b9b6965d078e3c7f95487a82d1c'] = 'Sauter';
|
$_LANGADM['AdminImport72ef2b9b6965d078e3c7f95487a82d1c'] = 'Sauter';
|
||||||
$_LANGADM['AdminImport76aeea9f48196068e6b47d46d41e7618'] = 'Afficher le prix (0 = Non, 1 = Oui)';
|
$_LANGADM['AdminImport76aeea9f48196068e6b47d46d41e7618'] = 'Afficher le prix (0 = Non, 1 = Oui)';
|
||||||
|
|||||||
Reference in New Issue
Block a user