Tuesday, 25 November 2014

Magento CSV import error show which row value is skipped

During the Batch CSV import, some of the rows will be skipped due to missing required values or any such errors. On the import process page magento will throw error message like below by default.

From this error message we won't be able to identify exactly which row is skipped. So I have made a modification to the magento files and after that


Now we will know which row is skipped and can check for errors in it. Let me explain the few modification which i did to achieve this.

Step 1:

copy the file Customer.php which is under the path "app/code/core/Mage/Customer/Model/Convert/Adaptor/" to this path "app/code/local/Mage/Customer/Model/Convert/Adaptor/"


Step 2:

open the Customer.php in your editor and look for the function name "saveRow". It will be around line 418.
Inside this function you will see the error messages text. For Example:

 $message = Mage::helper('customer')->__('Skipping import row, required field "%s" is not defined. ', 'website');

Replace above line with this.

 $message = Mage::helper('customer')->__('Skipping import row, required field "%s" is not defined. Unique value to identify in CSV <strong>%s</strong> ', 'website', $importData['email']);

There will be similar error messages thrown for various reasons like customer group not found. website id does not exist and so on.. You can use the above customization to all those errors thrown.

The $importData['email'] is the one which contains the row value which is unique in case on Customer import. you can also use $importData['firstname'] or $importData['lastname'] according to your needs. The values inside the quotes are the column names from the CSV.

Similarly For Product batch import you can modify the file which is under. app/code/core/Mage/Ccatalog/Model/Convert/Adaptor/Product.php 

NOTE: When you import the CSV. look for any Special characters. This may cause errors during import. To import CSV with special characters edit your .htaccess file and add this line to it AddDefaultCharset UTF-8

No comments:

Post a Comment