Zen Cart Logo
Forums / General Questions / upload category images via sql??

upload category images via sql??

Locked

Views: 2,370

Results 1 to 15 of 15
This thread is locked. New replies are disabled.
12 Feb 2008, 3:25 AM
#1
wtashby avatar

wtashby

Totally Zenned

Join Date:
Feb 2006
Posts:
594
Plugin Contributions:
0

upload category images via sql??

I'm not interested in installing and/or using EasyPopulate, which is why I'm posting this question. Is there a simple sql command , that I can use to upload (inject) images into my categories?

I don't mind spending the time to build the query, I just don't want my site down for the time it would take to input each and every image via admin. Again, please don't suggest EP.

Thanks

12 Feb 2008, 9:45 AM
#2
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: upload category images via sql??

The actual images (the jpg, gif or png files) are best uploaded in bulk via your FTP program. Several hundred can be transferred to your server in a matter of minutes, depending of course on the file size.

Easypopulate does not "upload images"... it writes information to the database.

So, you will use easypopulate to create the required references that "couple" your images to their respective products.

Easypopulate therefore, needs to know what image relates to what product code (model number).

So, after you have uploaded all your jpg/gif/png files to the images folder via FTP, you will use easypopulate to establish (in the database), the cross-reference that zencart needs to link an image (or several images) to a particular product via its product code (model number).

You will need - at the very least - to have appropriate data listed in TWO of easypopulate's columns:-

v_products_model

and

v_products_image

I ALWAYS name my images the same as the product code (model number),

So... if I have a list of product codes...

a000100
a000200
a000300 (etc)

my jpegs are named...

a000100.jpg
a000200.jpg
a000300.jpg (etc)

My easypopulate columns will look like this...

v_products_model >>>>> v_products_image
a000100 >>>>>>>>>>>> a000100.jpg
a000200 >>>>>>>>>>>> a000200.jpg
a000300 >>>>>>>>>>>> a000300.jpg

Naturally, you may choose to name your images any way you please, but the key is the relationship that is established between the v_products_model and the v_products_image.

12 Feb 2008, 10:03 AM
#3
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: upload category images via sql??

After posting the above, I see that you are "dead against" using easypopulate.

I find this odd... Why create a lot of extra work for yourself? Even if you build a SQL query, you are still going to have to MANUALLY write each "alter" or "insert" line on the query. (one for each product/image reference you update). The margin for error is very high.

Believe me... I manage my entire product lists (in once case over 4000 products) in MS Excel. Then, I use easypopulate to make changes. I must have saved hundreds and hundreds of hours using this system.

Easypopulate takes a couple of minutes to install, and lets you get on with what matters most, devoting time to encouraging customers to buy products - not tinkering for weeks on end with back-end code issues!

12 Feb 2008, 11:23 PM
#4
wtashby avatar

wtashby

Totally Zenned

Join Date:
Feb 2006
Posts:
594
Plugin Contributions:
0

Re: upload category images via sql??

The Free version of EP doesn't allow for uploading category images, and I am NOT going to pay for EP advanced.

That's why I said don't even mention EP to me. Not to mention I'm talking about CATEGORY images, not product images.

Does Anyone know how to write an sql snippet that will add (associate) an image to a category, and/or sub-category?

14 Feb 2008, 10:07 AM
#5
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: upload category images via sql??

Whether you're talking about CATEGORY images or PRODUCT images makes no difference...

You don't "upload" images via SQL...

Perhaps you mean this...

"How do I write the image reference to the database for Category Images to display?"

In which case my first line of interest is:-

Do you have access to phpMyAdmin?

If this is what you are trying to achieve, please indicate... Then I can try to assist.

14 Feb 2008, 10:21 AM
#6
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: upload category images via sql??

If you have access to phpMyAdmin, then you will need to write a SQL query that UPDATES the data.

Go here for a good tutorial...

http://www.analysisandsolutions.com/code/mysql-tutorial.htm#updating

15 Feb 2008, 5:21 PM
#7
wtashby avatar

wtashby

Totally Zenned

Join Date:
Feb 2006
Posts:
594
Plugin Contributions:
0

Re: upload category images via sql??

Whether you're talking about CATEGORY images or PRODUCT images makes no difference...

You don't "upload" images via SQL...

Try reading my last post again. I didn't say upload, I said associate! And never mind, I did it manually.

18 Feb 2009, 3:34 PM
#8
jjdoench avatar

jjdoench

New Zenner

Join Date:
Feb 2008
Posts:
41
Plugin Contributions:
0

Re: upload category images via sql??

schoolboy -

I don't know about the OP, but I would love to be able to update my category images via phpMyAdmin! I'm doing it manually right now after I had to erase a subcategory and recreate it - very tedious.

I currently use EP and Excel to manage my products, so I'm familiar with them. I read through the tutorial you linked to, but was a bit lost. I have a test setup on my home computer, so I could try out any instructions in a safe environment.

Here's what I want to do. Say I have 100 categories. I have images for the categories that are named "category.jpg". I can upload them to my images/categories folder. What do I do in phpMyadmin to write this information to my database?

I wish there was just a column for this info in EP...

Thanks in advance!
Jessica
Best Friends Quilt Shoppe
https://www.bestfriendsquilts.com

18 Feb 2009, 4:22 PM
#9
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: upload category images via sql??

There is no easy or fast way to do this - even in phpMyAdmin, or via a SQL command.

Let's examine why...

For a SQL command you would need to use "Insert Into" xxxxx "Where Category ID=" xxxxx (and perhaps a bit more command line stuff) then the VALUES to be inserted (then delimited values for each field)... This times 200 if you have 200 categories!

In phpMyAdmin, The image reference in in the CATEGORIES table, but the categories' NAMES are in the CATEGORIES_DESCRIPTION table...

... so you are going to have to either KNOW what each category ID refers to, or export the two tables, amalgamate them, then work out what image reference to insert...

(I suppose once you've done this, you could build a SQL coimmand that inserts the images against their appropriate category ID, but I'm no SQL expert so perhaps some GURU out there can help further??? )

18 Feb 2009, 7:17 PM
#10
jjdoench avatar

jjdoench

New Zenner

Join Date:
Feb 2008
Posts:
41
Plugin Contributions:
0

Re: upload category images via sql??

da%n...

thanks anyway!

guess that'll teach me not to mess up my categories again, eh? (backup, backup, then make sure you backed up the right stuff, then backup again)

Back to click, wait... click, click, wait... click, wait... wait... maybe I could get one of my kids to do this...

thx,
Jessica

18 Feb 2009, 8:17 PM
#11
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: upload category images via sql??

wtashby:

Try reading my last post again. I didn't say upload, I said associate! And never mind, I did it manually.Incredible :shocking:

18 Feb 2009, 8:48 PM
#12
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: upload category images via sql??

OKAY...

So let's assume you KNOW what Category ID's relate to what Category names and their associated images.

In my example, I know that:

  • Category ID 1 will need image1.jpg
  • Category ID 2 will need image2.jpg
  • Category ID 3 will need image3.jpg

Here's the SQL command I run:

UPDATE `categories` SET `categories_image` = 'image1.jpg' WHERE `categories_id` = 1;
UPDATE `categories` SET `categories_image` = 'image2.jpg' WHERE `categories_id` = 2;
UPDATE `categories` SET `categories_image` = 'image3.jpg' WHERE `categories_id` = 3;

(Notice correct use of back-quotes around the table columns, and single quotes around the image name).

So if you have 200 categories, you'll need 200 such UPDATE lines.

IT WOULD HELP YOU therefore, to NAME your category images the SAME AS the category ID.

So, for category ID 247, the image would be named image247.jpg (or just 247.jpg).

Then, all you need do is make sure that in each update line, the CAT ID and the IMAGE NAME are the same "number".

(You could actually compile this in a spreadsheet, then concatenate the cells to "create" the full lines. This will speed up the process considerably...)

18 Feb 2009, 8:53 PM
#13
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: upload category images via sql??

paulm:

Incredible :shocking:

Yeah... some people say "thanks" in funny ways... :mellow:

18 Feb 2009, 8:58 PM
#14
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: upload category images via sql??

BY THE WAY...

With regard to post #12...

If the images are stored in the images/category sub-folder, then you will need to include:

categories/

in the path:

eg:

UPDATE categories SET categories_image = '**categories/**image1.jpg' WHERE categories_id = 1;