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;
}
The text was updated successfully, but these errors were encountered:
mgesing
changed the title
Data importer always inserts new pictures, 'ProductService.FindEqualPicture(...)' does not detect equal pictures while importing
Data importer always inserts new pictures and does not detect equal pictures while importing
Sep 19, 2017
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:
A solution that seems to work is to (temporary) enable proxy creation in 'CategoryImporter' for the DbContext:
The text was updated successfully, but these errors were encountered: