excel import error

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 years ago
af1racing wrote:
RE: "SqlException: String or binary data would be truncated."

Look for one or more of your excel cells exceeding the width of the corresponding database column, like a Name, Sku or GTIN over 400 chars.

I've never used the excel import, but I imagine it's handling categories, images, and attributes, etc too, so that's a lot of columns to search.  I would start with 1 product at a time until you find the first that definitely fails.  Then use excel formulas on that 1 failed product to determine the guilty cell,  and truncate or handle as necessary for the remaining products in a final import.


That was the problem! Thanks for your help! Actually it was a "MetaDescription" that was very long I think. If not that, it was a couple SeName's that I shortened as well. But the MetaDescription was very long in a couple of them. Accidentally.
What I did to quickly find them is make the columns wider one column at a time and it was easy to see what stood out as being too long.
3 years ago
Hi
I'm having the same issue with 4.3 version .... I am trying to import from excel to change just 2 product  categories:
ProductId  SKU  Categories
263572  STH04205600000  cat-locker;Abbigliamento ed Accessori;Fascia 0-2;PROMOZIONI STIHL;
279230  STH41512000016-demo  cat-tntpoint;Fascia 10-20;SOTTOCOSTO;PROMOZIONI STIHL;

I have canceled the PROMOZIONI STIHL; saved and tried to import again the excel but I have faced the follow error:
Sequence contains no matching element

The log writes:
Tipo  
Errore
Messaggio breve  
Sequence contains no matching element
Messaggio completo  
System.InvalidOperationException: Sequence contains no matching element
   at System.Linq.ThrowHelper.ThrowNoMatchException()
   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
   at Nop.Services.ExportImport.ImportManager.<>c__DisplayClass54_2.<ImportProductsFromXlsx>b__11(Int32 categoryId) in D:\Sviluppo\Hobbystore430\Libraries\Nop.Services\ExportImport\ImportManager.cs:line 1676
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at Nop.Services.ExportImport.ImportManager.ImportProductsFromXlsx(Stream stream) in D:\Sviluppo\Hobbystore430\Libraries\Nop.Services\ExportImport\ImportManager.cs:line 1678
   at Nop.Web.Areas.Admin.Controllers.ProductController.ImportExcel(IFormFile importexcelfile) in C:\andrei\nop_sources\src\Presentation\Nop.Web\Areas\Admin\Controllers\ProductController.cs:line 2332

This is driving me crazy because I have to import 200 products without the PROMOZIONI STIHL categories...

Anyone knows what am I doing wrong?
Thanks in advance
lorenzo
3 years ago
Try just exporting only one of those products.  Make the update to Excel sheet, and then import.
3 years ago
Hi

I have done just with one product....I have exported 1 product and deleted the category "promozioni stihl" and uploaded the excel... nop 4.3 said that was everithing fine, nothing in the log but when I reloaded the category "promozioni stihl" the product was still there (was an unpublished product)

Then I have tried again with another product (published) and now nop wrote me

Sequence contains no matching element

And the log file was written:
Errore
Messaggio breve  
Sequence contains no matching element
Messaggio completo  
System.InvalidOperationException: Sequence contains no matching element
   at System.Linq.ThrowHelper.ThrowNoMatchException()
   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
   at Nop.Services.ExportImport.ImportManager.<>c__DisplayClass54_2.<ImportProductsFromXlsx>b__11(Int32 categoryId) in D:\Sviluppo\Hobbystore430\Libraries\Nop.Services\ExportImport\ImportManager.cs:line 1676
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at Nop.Services.ExportImport.ImportManager.ImportProductsFromXlsx(Stream stream) in D:\Sviluppo\Hobbystore430\Libraries\Nop.Services\ExportImport\ImportManager.cs:line 1678
   at Nop.Web.Areas.Admin.Controllers.ProductController.ImportExcel(IFormFile importexcelfile) in C:\andrei\nop_sources\src\Presentation\Nop.Web\Areas\Admin\Controllers\ProductController.cs:line 2332

I think I have something wrong in the db ....in the product's categories :-( Bad luck

Lorenzo
3 years ago
Your Exception is "Sequence contains no matching element"
There's a bug deleting Unpublished Categories.
The workaround is to Publish the Category(s) that you are removing from the product.  (And then you can unpublish them after you do the import.)

The problem is in the code in \Libraries\Nop.Services\ExportImport\ImportManager.cs
//delete product categories
var deletedProductCategories = categories.Where(categoryId => !importedCategories.Contains(categoryId))
    .Select(categoryId => _categoryService.GetProductCategoriesByProductId(product.Id).First(pc => pc.CategoryId == categoryId));



The showHidden should be passed in as 'true'"
_categoryService.GetProductCategoriesByProductId(product.Id, showHidden:true)

I'll open an issue in GitHub.
3 years ago
Infact this is an unpublished category.... That I m going to publish again In April..
OK I m glad is not my fault.
Thank you for your help
Lorenzo
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.