-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Description
Occures with CategoryImporter (ProductImporter and CustomerImporter?) in SmartStore v3.0.3.
CategoryImporter:
After getting an existing Category by 'categoryRepository.GetById(...)' the navigation property 'Picture' has a value for 'MediaStorageId' but 'MediaStorage' is NULL.
So the succeeding function 'ProductService.FindEqualPicture(...)' does not get any bytes of an existing picture from 'MediaStorageProvider' to compare with the new picture:
namespace SmartStore.Services.Media.Storage
{
public class DatabaseMediaStorageProvider : IMediaStorageProvider, ISupportsMediaMoving
{
public byte[] Load(MediaItem media)
{
...
return media.Entity?.**MediaStorage**?.Data ?? new byte[0];
}
}
}
A solution that seems to work is to (temporary) enable proxy creation in 'CategoryImporter' for the DbContext:
try
{
// We have to enable proxy creation to load binary values of current pictures.
// Otherwise FindEqualPicture does not work correctly.
context.Services.DbContext.ProxyCreationEnabled = true;
ProcessPictures(context, batch);
}
catch (Exception ex)
{
context.Result.AddError(ex, segmenter.CurrentSegment, "ProcessPictures");
}
finally
{
context.Services.DbContext.ProxyCreationEnabled = false;
}
Reactions are currently unavailable