Import products

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 Jahre weitere
Hi,

I am trying to import about 700 products with images from a mysql database (magento). We would like to switch to nopcommerce if there is a way of transferring the existing records. Some help or ideas would be much appeciated.

regards

mark
14 Jahre weitere
You should be able to use the export feature of Magento to get your products out. You can also grab your images from the directory. Then import into SQL Server. I have only imported from another system and not Magento, but I just wrote some scripts that inserted the data into the Nop tables. I then wrote a program that read in the images.

I hope this helps.

Tod
14 Jahre weitere
Hi Filjan,

Could you post the code for the program to import the images?

I've managed to import my products (~1000) to the DB via an XL file but I still have to manually add the images which is very time consuming.

Thanks!
14 Jahre weitere
this is some sample code, based on a linqtosql implementation i posted a few weeks ago
you have to fill the picturebinary field in a nop_picture table record with a byte array
hope this helps...

link the pictureid to your product record and that's it!

private static byte[] ConvertImageToByteArray(Image imageToConvert, ImageFormat formatOfImage)
        {
            byte[] Ret;
            using (MemoryStream ms = new MemoryStream())
            {
              imageToConvert.Save(ms, formatOfImage);
              Ret = ms.ToArray();
            }
            return Ret;
        }

        private int ImageImport(string url)
        {
            int iret = -1;
            var request = HttpWebRequest.Create(url);
            var response = request.GetResponse();
            using (Stream MyResponseStream = response.GetResponseStream())
            {
                Nop_Picture pict = new Nop_Picture();
                pict.PictureBinary = ConvertImageToByteArray(Image.FromStream(MyResponseStream), ImageFormat.Jpeg);
                pict.Extension = "image/pjpeg";
                pict.IsNew = false;
                NopCommerceContextHelper.GetNopDC().Nop_Pictures.InsertOnSubmit(pict);
                NopCommerceContextHelper.GetNopDC().SubmitChanges();
                iret = pict.PictureID;
            }
            return iret;
        }
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.