Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Script for Product-Image insert


vanGogh

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

Link to comment
Share on other sites

  • 3 weeks later...

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!

Link to comment
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

Link to comment
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"

Link to comment
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"

Link to comment
Share on other sites

  • 1 month later...

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?

Link to comment
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.

Link to comment
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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...