Import Products (but dont overwrite if Sku already exists)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 years ago
Hi,

Is it possible to not overwrite Products if the Sku already exists using the Admin/Products/ "Import" button?
I have Nop 4.2 Source code. I guess I would have to modify the Source Code to achieve this. Any ideas how & where?

Kind regards,
Joe
3 years ago
One way is not to put these products in the eXecl file

To change the code See source\src\Libraries\Nop.Services\ExportImport\ImportManager.cs
ImportProductsFromXlsx routine
Only do the code section if isNew

var product = metadata.SkuCellNum > 0 ? allProductsBySku.FirstOrDefault(p => p.Sku == metadata.Manager.GetProperty("SKU").StringValue) : null;
var isNew = product == null;
if (isNew)
{
// Do the rest
.....
}
3 years ago
Thanks, this is exactly what I was looking for.

I suggested to client not including the existing products in excel import file but client wants to safeguard against accidentally overwriting existing products
3 years ago
or, you can use this and not have to indent everything ;)

if (!isNew) continue;
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.