Jump to content
Sign in to follow this  
vanGogh

Script for Product-Image insert

Recommended Posts

Hello!

I'm looking for somebody who can write me a little php-script.

 

I have to upload several thousands products. But not for all I have a picture. So, what I like to have is a script, which searches the image-folder for available imagefiles and put these into the product-table.

 

The image-filename is identically to the products_model.

 

Can anybody help me?

 

Thanks in advance!

Stephen

Share this post


Link to post
Share on other sites

I think you are putting the cart before the horse. Or use someother backwards analogy :).

 

If the picture names are the same as the image filename, why would you query the database to retrieve the pic name? Just recode the product_info.php and default.php pages to use the part number + .gif and then dump all of the pics in the directory. That would lighten the server load a bit to to not run a query for that.

 

Does that help?

rp


I am a spender, but Jesus Saves!

Share this post


Link to post
Share on other sites

That is the easy way, if I have a picture for every product. But I don't. I only have pictures for a part of products, but put more in daily.

 

That is, why I need a script, which I can start any time to check for which products images are available.

 

Regards,

Stephen

Share this post


Link to post
Share on other sites

So are the products already in your database or do you need:

 

get *.jpg from images/

 

for each *.jpg insert into the database

 

new product = *

model = *

image = /images/*.jpg

 

 

Which you will only run once?


"Politics is the art of preventing people from taking part in affairs which properly concern them"

Share this post


Link to post
Share on other sites
I only have pictures for a part of products, but put more in daily.

 

Okay.. so you want the script to read the entire image directory into a big old array, and then do a query on the database for each picture name on the model field. If the modelfield == picturename you update the products image field with the picturename.jpg.

 

That should not be too hard to do but will cost resources if your directory holds thousands of pictures.


"Politics is the art of preventing people from taking part in affairs which properly concern them"

Share this post


Link to post
Share on other sites

I am just curious as to if this ever went anywhere, I have basically the same problem,

15000 products 2500 images

images are names the same as the product so I used easy populate to import my prods and simply put the product name+.gif at the end in the image column in excel.

 

Problem is what about the 12500 products that have no image? system will look for the image I placed in the column and not find it, so it will put out the red x

I would think that it would be fairly easy to write a small script that says,,

 

ok look for the image that was given, If it can't be found, just default to this image.

 

Can this be done?


Programmers are currently trying to make the next idiot proof software

 

The universe is currently trying to make the next idiot

 

The universe is winning

Share this post


Link to post
Share on other sites

An even better solution would be to mod the picture display parts so that wheneever a link to a picture is to be displayed, its existance is checked first, and if not available a default "no picture" link is inserted instead.

The "no picture" should be configurable from admin, of course. Maybe different pictures depending on category or other params.

 

This way you just check the actually chosen images from the file system at run time. The "no picture" will show until the second you upload the image.

 

Just an idea for a mod.

Share this post


Link to post
Share on other sites

I agree, This would be a go contibution, especially for those of us who use import contribs like easy populate, for large numbers of products,.


Programmers are currently trying to make the next idiot proof software

 

The universe is currently trying to make the next idiot

 

The universe is winning

Share this post


Link to post
Share on other sites

We understand that there are default image contribs, But I do not belive that they will show a default image if you asign the product a image that is not found. You would have to leave the image field empty, and to go in and empty the image fiel on 12500 out of 15000 products would be insane.


Programmers are currently trying to make the next idiot proof software

 

The universe is currently trying to make the next idiot

 

The universe is winning

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×