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.
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.
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.
Hâlen sorularınız mı var veya yardıma mı ihtiyacınız var?