Importing Images / Data Migration

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 years ago
Hi Everyone,
I am currently working on a project migrating an existing project to nopCommerce 1.80. I've gone through and mapped most of the database tables but I've ran into a bit of a problem on the images.

Images are stored on the filesystem on the existing db. I installed nopCommerce, changed the setting to store images on the filesystem, copied over the existing images from the old ecommerce software and then went to figure out how the images are referenced.

I noticed that when stored on the filesystem an entry is created in the nop_Picture table and the picture is stored in the images folder with a name that matches the PictureID, so in my case I added an image and it got the id 173 in the db and the name 0000173_0.jpg on the file system.

On the old system images are named according to the sku followed by a picture size (t for thumbnails, s for smal, m for medium, l for large). A product image is referenced in the old db like '/images/d5789_m' for example. What would be the easiest way to import the old images into nopCommerce?

I was thinking about adding another column to Nop_Picture called Image_Location and inserting the values from the old db into that column. I would then write a program in c# that would look up all the image locations, find the file and rename it according to the PictureID. This seems like a lot of work to import the pictures. Any other suggestions or guidlines for the program I am thinking about writing if that is the only way?
13 years ago
devgineer wrote:
Hi Everyone,
I am currently working on a project migrating an existing project to nopCommerce 1.80. I've gone through and mapped most of the database tables but I've ran into a bit of a problem on the images.

Images are stored on the filesystem on the existing db. I installed nopCommerce, changed the setting to store images on the filesystem, copied over the existing images from the old ecommerce software and then went to figure out how the images are referenced.

I noticed that when stored on the filesystem an entry is created in the nop_Picture table and the picture is stored in the images folder with a name that matches the PictureID, so in my case I added an image and it got the id 173 in the db and the name 0000173_0.jpg on the file system.

On the old system images are named according to the sku followed by a picture size (t for thumbnails, s for smal, m for medium, l for large). A product image is referenced in the old db like '/images/d5789_m' for example. What would be the easiest way to import the old images into nopCommerce?

I was thinking about adding another column to Nop_Picture called Image_Location and inserting the values from the old db into that column. I would then write a program in c# that would look up all the image locations, find the file and rename it according to the PictureID. This seems like a lot of work to import the pictures. Any other suggestions or guidlines for the program I am thinking about writing if that is the only way?


You do not need to add another column. Just figure out what t, s, and m translate to in dimensions and reference the images like: PictureManager.GetPictureUrl(imageID, targetSize, false) and the targetSize will be the dimension of the t, s, or m dimension that you used before.

Also, I have implemented my own solution, based on an idea I saw here in these forums, to add a file name in front of the file name that nopCommerce references. All you have to do is edit a few lines in the PictureManager class. Where ever you see the: "{0}_.*" or "{0}*" or whatever, replace it with "{0}_{1}" where {0} is your custom file name and {1} is the original nopCommerce file reference. Once nopCommerce has saved the file with your custom file name configuration, it will always reference it in future binary loads.
13 years ago
deccks wrote:

You do not need to add another column. Just figure out what t, s, and m translate to in dimensions and reference the images like: PictureManager.GetPictureUrl(imageID, targetSize, false) and the targetSize will be the dimension of the t, s, or m dimension that you used before.

Also, I have implemented my own solution, based on an idea I saw here in these forums, to add a file name in front of the file name that nopCommerce references. All you have to do is edit a few lines in the PictureManager class. Where ever you see the: "{0}_.*" or "{0}*" or whatever, replace it with "{0}_{1}" where {0} is your custom file name and {1} is the original nopCommerce file reference. Once nopCommerce has saved the file with your custom file name configuration, it will always reference it in future binary loads.


Thank you for the quick reply. I'm new to nopCommerce so your solutions are confusing me a bit. If I have a file name e8700_m.jpg for example how would I insert it into the DB and know what file it references I don't add an extra column (file location)?

With the second solution wouldn't nop look for e8700_m.jpg_000000173.jpg?

Sorry that I am not understanding you correctly, but I'm using straight sql for the data migration.
13 years ago
Why not just store the images in the DB unless you're doing this for performance / size reasons?
13 years ago
The current shopping cart stores the images on the file system, I was hoping that I would be able to just import the column that stores the image location into the db and then do a join to figure out which image goes with which product.

Also the store owner is running SQL Express (4 GB limit) and there are over 8,000 products. I don't want to run into any issues with hitting the maximum limit as there is close to 600mb of data in the db without any binary data stored in it.

Maybe my question should be
What is the best way to import images into nopCommerce from an existing store that hosts images on the file system?

Would appreciate any steps, guidelines from users who have done this before.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.