Best way to create Image thumbnails while importing bulk data from another application

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
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?
12 years ago
Forgive me if I'm totally off here...

Do you really need to creat the thumbs? As far as 1.x is concerned, the thumbs were created automatically when the image was first requested.
12 years ago
>> Best way to create Image thumbnails while importing bulk data from another application . . .

Is it possible to import a product image for a product when using Import?
12 years ago
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
12 years ago
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.

I already handled my problem by directly writing data to database.But as you suggest what i really wanted to do is using PictureService. But thats where problems start.Because when i want to create an instance of PictureService it needs NopcommerceContext as parameter. I cant create a working nopcommerce context. I made a working connection but its just getting null so cant use it. Can you share a sample or give me an idea of how i will create a nopcontext from another application? Thanks
12 years ago
By the way i use 1.9
12 years ago
I tried to figure out how to initialize everything on a web.config and a lot has changed from 1.80/1.90. They are using Unity and I have no clue yet how to deal with all that.

When I get a chance I'll poke the code around and try figuring it out. If you do figure it out, let me know please! :)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.