Skip to content

Commit ca4fc51

Browse files
committed
Product import: force to use the pipe symbol as separator for image URLs because file names can contain commas or semicolons
1 parent b28e7e3 commit ca4fc51

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/Libraries/SmartStore.Services/Catalog/Importer/ProductImporter.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -868,12 +868,15 @@ protected virtual void ProcessProductPictures(ImportExecuteContext context, IEnu
868868

869869
foreach (var row in batch)
870870
{
871-
var imageUrls = row.GetDataValue<List<string>>("ImageUrls");
872-
if (imageUrls.IsNullOrEmpty())
871+
var rawImageUrls = row.GetDataValue<string>("ImageUrls");
872+
873+
// Force pipe symbol as separator because file names can contain commas or semicolons.
874+
var imageUrls = rawImageUrls.SplitSafe("|");
875+
if (imageUrls.Length == 0)
873876
{
874877
continue;
875878
}
876-
879+
877880
var productId = row.Entity.Id;
878881
var imageNumber = 0;
879882
var displayOrder = -1;
@@ -883,10 +886,17 @@ protected virtual void ProcessProductPictures(ImportExecuteContext context, IEnu
883886
// Collect required image file infos.
884887
foreach (var urlOrPath in imageUrls)
885888
{
886-
var image = CreateDownloadImage(context, urlOrPath, ++imageNumber);
889+
try
890+
{
891+
var image = CreateDownloadImage(context, urlOrPath, ++imageNumber);
887892

888-
if (image != null)
889-
imageFiles.Add(image);
893+
if (image != null)
894+
imageFiles.Add(image);
895+
}
896+
catch
897+
{
898+
context.Result.AddWarning($"Failed to prepare image download for '{urlOrPath.NaIfEmpty()}'. Skipping file.", row.GetRowInfo(), "ImageUrls");
899+
}
890900

891901
if (imageFiles.Count >= numberOfPictures)
892902
break;

0 commit comments

Comments
 (0)