Forums / General Questions / Help please: adding "options" to products (sql query)

Help please: adding "options" to products (sql query)

Locked

Views: 1,907

Results 1 to 20 of 20
This thread is locked. New replies are disabled.
16 Feb 2008, 6:19 PM
#1
sjku avatar

sjku

New Zenner

Join Date:
Jan 2008
Location:
india
Posts:
8
Plugin Contributions:
0

Help please: adding "options" to products (sql query)

Hello,
I'm working on a zen cart site, and I need to add 3 options to every product in database. For some products I need to add 4. There are many products listed in my db, so instead of doing it manually, I was thinking of doing it with php and queries.

My problem is that I don't know where to add (table/field name) so that all products can show their appropriate option.
Can someone please give me a SQL query, or just let me know which table to add "product option" in, and most important how to connect options to products.
Thanks in advance for the help :)
s.Jeet

16 Feb 2008, 8:10 PM
#2
marg avatar

marg

Totally Zenned

Join Date:
Mar 2004
Posts:
642
Plugin Contributions:
0

Re: Help please: adding "options" to products (sql query)

Why not just create the attributes for 2 products - the 2 different ones with different options, then use the copy option to category using the attributes controller? Or have I totally misread your dilemma?
Marg

16 Feb 2008, 9:12 PM
#3
sjku avatar

sjku

New Zenner

Join Date:
Jan 2008
Location:
india
Posts:
8
Plugin Contributions:
0

Re: Help please: adding "options" to products (sql query)

Hi Marg,
I don't know about adding attributes as well...
Most of these options are different. They are actually color information for different products. Some of them have (red,green) while others may have (black, blue etc)
Is there a simple process I can follow to add these using SQL queries? Like I first add to attributes table (I don't know fields) generating an autoincrement number, I put this number with some other info to some other table (I don't know table/field) and so on...
Please let me know the process/steps for this.
Thank you :)

16 Feb 2008, 9:24 PM
#4
marg avatar

marg

Totally Zenned

Join Date:
Mar 2004
Posts:
642
Plugin Contributions:
0

Re: Help please: adding "options" to products (sql query)

I think you'll find that what you are trying to do will not work as you expect. If you'd like me to take a look, please feel free to pm me.
Marg

16 Feb 2008, 9:31 PM
#5
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Help please: adding "options" to products (sql query)

It sounds like you are trying to achieve customized results with a blanket approach. This is unlikely to work without actually, well, customizing whatever method you use. Whatever you do will require a separate base for each combination you want to apply.

16 Feb 2008, 10:48 PM
#6
sjku avatar

sjku

New Zenner

Join Date:
Jan 2008
Location:
india
Posts:
8
Plugin Contributions:
0

Re: Help please: adding "options" to products (sql query)

Hi,
Can you please tell me which page/functions are being used to display the "detailed" product page, and where can I find these files?
Thank you :)

16 Feb 2008, 10:50 PM
#7
marg avatar

marg

Totally Zenned

Join Date:
Mar 2004
Posts:
642
Plugin Contributions:
0

Re: Help please: adding "options" to products (sql query)

includes/templates/template_default/product_info.php
Else includes/templates/your_template/product_info.php
M

16 Feb 2008, 10:59 PM
#8
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Help please: adding "options" to products (sql query)

/includes/templates/your_template/templates/tpl_product_info_display.php.

What might work best for you is to set up base products with full sets of attributes, like all of the colors that are likely to be used. Bulk copy those to categories, and go through the products and delete the colors that do not apply. Quicker than adding new attributes.

16 Feb 2008, 11:20 PM
#9
marg avatar

marg

Totally Zenned

Join Date:
Mar 2004
Posts:
642
Plugin Contributions:
0

Re: Help please: adding "options" to products (sql query)

What a nut... I hate when I do that... Wrong file..
I agree 100% with gjh42
M

17 Feb 2008, 12:08 AM
#10
sjku avatar

sjku

New Zenner

Join Date:
Jan 2008
Location:
india
Posts:
8
Plugin Contributions:
0

Re: Help please: adding "options" to products (sql query)

Hello,
Thanks :) I found the files. My problem is that I have to update the db with a XML feed, so the manual interface of admin won't work in this case. I need to extract data from that feed using php, and then update the db with this info.

The methods you mentioned are very useful if I could used admin panel, but that's not an option... I should have mentioned this before. I'm so sorry...
Thank you for the files. I'll try to figure that out (which I'm not sure I'll be able to.)

If you guys figure out something, or have some queries I can use, then please let me know.
Thanks :)

17 Feb 2008, 12:25 AM
#11
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Help please: adding "options" to products (sql query)

Have you looked at the EasyPopulate mod? It is designed to transfer products from an external db to Zen Cart. Once you have products configured in that, new ones should be simple to set up.

See the support thread for more info and help on using it.

For the product info page, what kind of changes do you want to make? It is designed to be able to alter the layout easily by moving labeled blocks of code around, and editing the stylesheet.

17 Feb 2008, 2:18 AM
#12
sjku avatar

sjku

New Zenner

Join Date:
Jan 2008
Location:
india
Posts:
8
Plugin Contributions:
0

Re: Help please: adding "options" to products (sql query)

Hello Glenn,
I have already populated the database with products from feeds. They are also showing up in appropriate categories. I'll try to explain my problem better:

I have 6 main categories. All of them sub categories under them . These sub categories further have sub categories.

Now I extract product info from a xml feed. 1 main level category has products with options. Most sub categories under this main one also have options. Other 5 categories do not have any options. Only this 1 main category and it's sub cats.

I cannot import data from a db, because all I got is a xml feed. This is the reason why I need to know how to add these options to my zen cart installation.
Once I know this, I can then go ahead and code it up in php...
(cannot use the admin panel for this same reason.)

I'm getting so confused because of multiple tables. I have no idea where to put the options first, which data to use to connect this table to another table of values, and how to identify/connect an option with a product.

From the last posts of yours, 1 thing got clear that the option first needs to be added to "attributes" table. This is where I store product_id. but what to do after that is confusing me.

I'm pretty sure that once we figure this out, adding options with php code is going to be easy.

Thank you so much for your help so far. :) I sincerely appreciate you for taking the time to help a complete stranger.
Thanks :)

17 Feb 2008, 3:44 AM
#13
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Help please: adding "options" to products (sql query)

Are you saying that you don't have any access to the Zen Cart admin panel at all?
I would think it would ease the task if you could create option names and option values in admin; then populating attributes for individual products should be easier. You need option name and value ids before you can add attributes to the database.

The wiki has a database schema that describes the tables and their fields. It may or may not give a full plain-english description of what every field is for, but it would probably be a big step in the right direction.

17 Feb 2008, 3:53 AM
#14
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Help please: adding "options" to products (sql query)

http://www.zen-cart.com/wiki/index.php/Table_products_attributes

I think this and possibly some other table descriptions will help you out.

17 Feb 2008, 7:32 AM
#15
sjku avatar

sjku

New Zenner

Join Date:
Jan 2008
Location:
india
Posts:
8
Plugin Contributions:
0

Re: Help please: adding "options" to products (sql query)

Hi,
Yes, you are right, I don't have access to admin panel at all. Can only upload a file which processes a xml file to add products, and their options.
The link you gave above has been pretty useful. I'll try to figure out things using this, and will post here if I miss something.
For now I think this is how it works: (using what you posted, and the description given on that link)

We add a set of options, and their values.
When we want to add these options and values to any products, we simply add an entry in attribute. Is that right?
Thanks so much for your help in this matter. I sincerely appreciate.
Thank you.

17 Feb 2008, 8:12 AM
#16
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Help please: adding "options" to products (sql query)

I'm just curious as to how you can be working on a site and not have access to the site admin... So you can't change any admin settings either? Who can do that? Someone has to be able to.
If it's a matter of someone wanting to keep absolute control of the site, the Admin Profiles mod in Downloads will let them give you access to only the parts you need to use - like products and attributes.
It just seems like you are being hobbled and I don't see why that should be so.

17 Feb 2008, 6:23 PM
#17
sjku avatar

sjku

New Zenner

Join Date:
Jan 2008
Location:
india
Posts:
8
Plugin Contributions:
0

Re: Help please: adding "options" to products (sql query)

Hi,
Please don't get me wrong. I do have access to admin panel, bbut I'm only a web designer working on a client site. My client wants me to code up a feed extracting file for them, so they can load products from a certain site simply by opening the "feed code parser" in browser.
I did ask them to make the options in admin panel, but their reply was, "please do it in the feed itself" to be their exact words.
This is why I said that I don't have admin panel access. Just knowing the password etc is no use, unless I have permission to use it...

I did give them a feed parser to import products without adding options (works fine), so they can add them later from admin panel, but they still want this coded up in feed parser itself

This is my exact situation here.
I'm working on this, and will post here if I get success in this. Please let me know if you found out something.
Thank you a thousand times for helping me so far.
Thanks

17 Feb 2008, 9:49 PM
#18
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Help please: adding "options" to products (sql query)

I guess the customer is always right, even when they want something really stupid...

If they're willing to pay you to do all of the work for them forever by building this magic parser, ok. (I hope you're getting paid well for it:)

20 Feb 2008, 11:10 AM
#19
sjku avatar

sjku

New Zenner

Join Date:
Jan 2008
Location:
india
Posts:
8
Plugin Contributions:
0

Re: Help please: adding "options" to products (sql query)

Hi Glen,
Sorry for delayed response. I quoted $45 to the client, but had no idea that this was going to be this difficult. But anyway no regrets as the client is my number 1 client (top priority). Still haven't figured out anything, but work in progress.
Thank you a million times for your help in this matter.
Best regards

20 Feb 2008, 12:31 PM
#20
schoolboy avatar

schoolboy

Totally Zenned

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

Re: Help please: adding "options" to products (sql query)

I'd have a frank chat with the client to outline the challenges their desired "method" is creating, and that (in the interest of getting the product data accurate and functional right now) it would be prudent to do this using standard zencart admin tools (including easypopulate).

When the site is working, start to focus on the xml parser... In that way the site is up and running (and open for business), and you can focus your efforts on the parser issue...

(Just a suggestion :smile:

20 years a Zencart User