pıyrazyilmaz wrote:I wrote a windows form application to transfer data from xml to nopcommerce. Everything is fine except one thing.
I save images on file system and I can't create the thumbnails as nopcommerce uses to insert product Picture.
Because i tried everything but couldnt use PictureService or ProductService from another application because NopContext object that i create is not working. Is there an alternative way to do this? or is it possible to use PictureService out of the box?
There are a few ways to achieve what you want:
1 - write the data straight to the DB. You have to create a Picture record for each image, then create a Product_Picture_Mapping with the product ID and the picture ID. This way you write straight to the DB and avoid having to call nopcommerce libraries. Easier of the 3 solutions. I'm not sure if anything else is involved but I don't think so.
Pictures can be stored in DB or in the file system as far as I can remember and I think the default is in DB. Forgive me if I'm mistaken. Just take a look at the InsertPicture function on the PictureService (probably) and see how it's handled.
2 - Set up the services using the app.config file for your windows form application pretty much the same way it is setup in web.config and go tweaking until thinks like GetAllProducts work. Then call the PictureService.InsertPicture. This was simple to do on 1.90 and before, I'm not 100% sure it's still simple as I have no idea how things are setup now. It should follow the same idea. I'd probably go for this solution.
3 - Write you application so that it can imitate user steps by logging into the administrator page with a username and password and then submit http requests to the application with your photos. It's probably the most painful of the 3 methods but it's fun to do.
I'm sorry if some of the things I've said don't apply anymore, I just didn't have too much time to poke nopcommerce 2.0 code.
Good luck