Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data importer always inserts new pictures and does not detect equal pictures while importing #1268

iherwald opened this issue Sep 19, 2017 · 1 comment


Copy link

@iherwald iherwald commented Sep 19, 2017

Occures with CategoryImporter (ProductImporter and CustomerImporter?) in SmartStore v3.0.3.

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:

	// 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");
	context.Services.DbContext.ProxyCreationEnabled = false;
@muratcakir muratcakir added this to the 3.0.3 milestone Sep 19, 2017
@mgesing 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
@mgesing mgesing removed the review label Sep 19, 2017
Copy link

@mgesing mgesing commented Sep 19, 2017

Thank you for reporting.

mgesing added a commit that referenced this issue Sep 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

3 participants