Skip to content

Commit 21cb55e

Browse files
committed
Data exporter offers relative URL of product pictures
1 parent 10d8da7 commit 21cb55e

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/Libraries/SmartStore.Services/DataExchange/Export/DynamicEntityHelper.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,14 +386,14 @@ private dynamic ToDynamic(DataExporterContext ctx, Picture picture, int thumbPic
386386
return null;
387387

388388
dynamic result = new DynamicEntity(picture);
389+
var relativeUrl = _pictureService.Value.GetPictureUrl(picture, 0, false);
389390

391+
result._FileName = relativeUrl.Substring(relativeUrl.LastIndexOf("/") + 1);
392+
result._RelativeUrl = relativeUrl;
390393
result._ThumbImageUrl = _pictureService.Value.GetPictureUrl(picture, thumbPictureSize, false, ctx.Store.Url);
391394
result._ImageUrl = _pictureService.Value.GetPictureUrl(picture, detailsPictureSize, false, ctx.Store.Url);
392395
result._FullSizeImageUrl = _pictureService.Value.GetPictureUrl(picture, 0, false, ctx.Store.Url);
393396

394-
var relativeUrl = _pictureService.Value.GetPictureUrl(picture);
395-
result._FileName = relativeUrl.Substring(relativeUrl.LastIndexOf("/") + 1);
396-
397397
result._ThumbLocalPath = _pictureService.Value.GetThumbLocalPath(picture);
398398

399399
return result;
@@ -773,11 +773,21 @@ private dynamic ToDynamic(
773773
if (ctx.Supports(ExportFeatures.CanIncludeMainPicture))
774774
{
775775
if (productPictures != null && productPictures.Any())
776-
dynObject._MainPictureUrl = _pictureService.Value.GetPictureUrl(productPictures.First().Picture, ctx.Projection.PictureSize, storeLocation: ctx.Store.Url);
776+
{
777+
var firstPicture = productPictures.First().Picture;
778+
dynObject._MainPictureUrl = _pictureService.Value.GetPictureUrl(firstPicture, ctx.Projection.PictureSize, storeLocation: ctx.Store.Url);
779+
dynObject._MainPictureRelativeUrl = _pictureService.Value.GetPictureUrl(firstPicture, ctx.Projection.PictureSize);
780+
}
777781
else if (!_catalogSettings.Value.HideProductDefaultPictures)
782+
{
778783
dynObject._MainPictureUrl = _pictureService.Value.GetDefaultPictureUrl(ctx.Projection.PictureSize, storeLocation: ctx.Store.Url);
784+
dynObject._MainPictureRelativeUrl = _pictureService.Value.GetDefaultPictureUrl(ctx.Projection.PictureSize);
785+
}
779786
else
787+
{
780788
dynObject._MainPictureUrl = null;
789+
dynObject._MainPictureRelativeUrl = null;
790+
}
781791
}
782792

783793
if (ctx.Supports(ExportFeatures.UsesSkuAsMpnFallback) && product.ManufacturerPartNumber.IsEmpty())

0 commit comments

Comments
 (0)