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 318aab2b1..be24c380c 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 @@ -39,7 +39,7 @@ {/if} {if $module_confirmation} -
+
{l s='Your .CSV file has been sucessfully imported into your shop.'}
{/if} @@ -134,31 +134,30 @@
{l s='Import'} - -
- -
- {if count($files_to_import)} - - {/if} -    + {if count($files_to_import)} + + {/if} +   Uplaod{l s='Upload'}
-
+ + +
+ +
@@ -192,7 +191,8 @@
- + + {if empty($files_to_import)}{l s='You must upload a file for go to the next step.'}{/if}

{l s='Note that the category import does not support categories of the same name.'}

@@ -205,9 +205,8 @@

{l s='There is no CSV file available, please upload one using the \'Upload\' button above.'}

{/if} diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index e0da0e34b..f07ab38aa 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -423,7 +423,6 @@ class AdminImportControllerCore extends AdminController $warnings = array(); foreach ($this->warnings as $warning) $warnings[] = $warning; - $this->displayWarning($warnings); } $files_to_import = scandir(_PS_ADMIN_DIR_.'/import/'); @@ -574,7 +573,13 @@ class AdminImportControllerCore extends AdminController // toolbar (save, cancel, new, ..) $this->initToolbar(); if ($this->display == 'import') - $this->content .= $this->renderView(); + if (Tools::getValue('csv')) + $this->content .= $this->renderView(); + else + { + $this->errors[] = $this->l('You must upload a file for go to the next step'); + $this->content .= $this->renderForm(); + } else $this->content .= $this->renderForm(); @@ -1240,28 +1245,36 @@ class AdminImportControllerCore extends AdminController { $product_has_images = (bool)Image::getImages($this->context->language->id, (int)$product->id); foreach ($product->image as $key => $url) + { + $error = false; if (!empty($url)) { $image = new Image(); $image->id_product = (int)$product->id; $image->position = Image::getHighestPosition($product->id) + 1; $image->cover = (!$key && !$product_has_images) ? true : false; - if (($field_error = $image->validateFields(UNFRIENDLY_ERROR, true)) === true && + if (!file_exists($url)) + $error = true; + else if (($field_error = $image->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $image->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $image->add()) { // associate image to selected shops $image->associateTo($shops); if (!AdminImportController::copyImg($product->id, $image->id, $url)) - $this->warnings[] = Tools::displayError('Error copying image:').$url; + $this->warnings[] = Tools::displayError('Error copying image:').' '.$url; } else - { - $this->warnings[] = (isset($image->id_product) ? ' ('.$image->id_product.')' : ''). - ' '.Tools::displayError('Cannot be saved'); - $this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : ''). - Db::getInstance()->getMsgError(); - } + $error = true; } + else + $error = true; + + if ($error) + { + $this->warnings[] = sprintf(Tools::displayError('Product n°%1$d : the picture cannot be saved : %2$s'), $image->id_product, $url); + $this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : '').Db::getInstance()->getMsgError(); + } + } } if (isset($product->id_category)) $product->updateCategories(array_map('intval', $product->id_category)); @@ -1347,8 +1360,7 @@ class AdminImportControllerCore extends AdminController } else { - $this->warnings[] = (isset($image->id_product) ? ' ('.$image->id_product.')' : ''). - ' '.Tools::displayError('Cannot be saved'); + $this->warnings[] = (isset($image->id_product) ? ' ('.$image->id_product.')' : '').' '.Tools::displayError('Cannot be saved'); $this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : '').mysql_error(); } } @@ -2240,45 +2252,51 @@ class AdminImportControllerCore extends AdminController } else if (Tools::getValue('import')) { - if (Tools::getValue('truncate')) - $this->truncateTables((int)Tools::getValue('entity')); - - switch ((int)Tools::getValue('entity')) + // Check if the CSV file exist + if (Tools::getValue('csv')) { - case $this->entities[$this->l('Categories')]: - $this->categoryImport(); - break; - case $this->entities[$this->l('Products')]: - $this->productImport(); - break; - case $this->entities[$this->l('Customers')]: - $this->customerImport(); - break; - case $this->entities[$this->l('Addresses')]: - $this->addressImport(); - break; - case $this->entities[$this->l('Combinations')]: - $this->attributeImport(); - break; - case $this->entities[$this->l('Manufacturers')]: - $this->manufacturerImport(); - break; - case $this->entities[$this->l('Suppliers')]: - $this->supplierImport(); - break; - // @since 1.5.0 - case $this->entities[$this->l('SupplyOrders')]: - if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) - $this->supplyOrdersImport(); - break; - // @since 1.5.0 - case $this->entities[$this->l('SupplyOrdersDetails')]: - if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) - $this->supplyOrdersDetailsImport(); - break; - default: - $this->errors[] = $this->l('Please select what you would like to import'); + if (Tools::getValue('truncate')) + $this->truncateTables((int)Tools::getValue('entity')); + + switch ((int)Tools::getValue('entity')) + { + case $this->entities[$this->l('Categories')]: + $this->categoryImport(); + break; + case $this->entities[$this->l('Products')]: + $this->productImport(); + break; + case $this->entities[$this->l('Customers')]: + $this->customerImport(); + break; + case $this->entities[$this->l('Addresses')]: + $this->addressImport(); + break; + case $this->entities[$this->l('Combinations')]: + $this->attributeImport(); + break; + case $this->entities[$this->l('Manufacturers')]: + $this->manufacturerImport(); + break; + case $this->entities[$this->l('Suppliers')]: + $this->supplierImport(); + break; + // @since 1.5.0 + case $this->entities[$this->l('SupplyOrders')]: + if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) + $this->supplyOrdersImport(); + break; + // @since 1.5.0 + case $this->entities[$this->l('SupplyOrdersDetails')]: + if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) + $this->supplyOrdersDetailsImport(); + break; + default: + $this->errors[] = $this->l('Please select what you would like to import'); + } } + else + $this->errors[] = $this->l('You must upload a file for go to the next step'); } parent::postProcess(); diff --git a/translations/fr/admin.php b/translations/fr/admin.php index e70173974..0bd1bb3da 100644 --- a/translations/fr/admin.php +++ b/translations/fr/admin.php @@ -1540,6 +1540,7 @@ $_LANGADM['AdminImporte92cfa244b5eb9025d07522080468445'] = 'Écotaxe'; $_LANGADM['AdminImportea4788705e6873b424c65e91c2846b19'] = 'Annuler'; $_LANGADM['AdminImporteafce46b9013f4d12336785c388b664c'] = 'Exemple de fichier de adresses'; $_LANGADM['AdminImporteb931783a286222455893fb956d52cc9'] = 'Vous pouvez lire des informations sur l\'import CSV sur :'; +$_LANGADM['AdminImportec135b63c4cd152420ce2c5c37666b88'] = 'Vous devez télécharger un fichier pour aller à la prochaine étape.'; $_LANGADM['AdminImportec136b444eede3bc85639fac0dd06229'] = 'Fournisseur'; $_LANGADM['AdminImportecc2c839377d44e39486e231322de623'] = 'ID règles de taxes'; $_LANGADM['AdminImportecde3e896afb64e9a48781b8363b9a03'] = 'Caractéristique(Nom:Valeur:Position)';