Forums / Setting Up Categories, Products, Attributes / How To Add New Product Fields?

How To Add New Product Fields?

Views: 83,922

Results 21 to 40 of 159
3 Jun 2009, 6:16 PM
#21
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

How To Add New Product Fields?

All of your products must exist in the new database table. If you had existing products, you must add them to the new table. from the readme file:

If you are installing this into a cart that already has products, you will have to populate the new table with every product id in order for the products to be visible. This is not hard to do with excel and phpmyadmin. If you have access to your database, export the file to excel, add the fields and import it back in.

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

3 Jun 2009, 6:17 PM
#22
greengreetings avatar

greengreetings

Zen Follower

Join Date:
May 2009
Location:
Virginia
Posts:
90
Plugin Contributions:
0

Re: How To Add New Product Fields?

All of my product pages are screwed up now. I think I'm going to revert back to the default and try Delia's download. I just want an extra text field for a heading is all.

3 Jun 2009, 6:17 PM
#23
greengreetings avatar

greengreetings

Zen Follower

Join Date:
May 2009
Location:
Virginia
Posts:
90
Plugin Contributions:
0

Re: How To Add New Product Fields?

delia:

All of your products must exist in the new database table. If you had existing products, you must add them to the new table. from the readme file:

If you are installing this into a cart that already has products, you will have to populate the new table with every product id in order for the products to be visible. This is not hard to do with excel and phpmyadmin. If you have access to your database, export the file to excel, add the fields and import it back in.

Can you be more specific? Or rather, is there a way to start from the beginning?

4 Jun 2009, 5:25 PM
#24
greengreetings avatar

greengreetings

Zen Follower

Join Date:
May 2009
Location:
Virginia
Posts:
90
Plugin Contributions:
0

Re: How To Add New Product Fields?

delia:

All of your products must exist in the new database table. If you had existing products, you must add them to the new table. from the readme file:

Does the information from the table products_description also go in the new database table? I got the field to show up in my admin to fill out, but all of my product pages are blank. Thank you for explaining the above. I'm starting to understand better now!

5 Jun 2009, 2:25 AM
#25
aliepinieks avatar

aliepinieks

Zen Follower

Join Date:
Jun 2009
Location:
Brisbane, QLD AUS
Posts:
209
Plugin Contributions:
0

Re: How To Add New Product Fields?

easypopulate modifications went pretty smoothly for me, however i didn't 'futureproof' for upgrades as outlined earlier in this thread. i simply added "xxxx_id" fields to the products table, and created additional tables without a product_id index (same as manufacturer) so i guess i'll have to dump these tables and the products table data to file before upgrading. silly me!

as far as modifying easypopulate is concerned, i just modified each of the easypopulate files (you can search for them using the developers toolkit in the admin section) to include:

a) the new field variables, names and rules for the import file
b) the sql to insert the additional column data (obviously matching it up with what i changed in mysql)

this was pretty simple for me because i simply copied every reference to 'manufacturer' and changed to suit, however because i did not follow the method used here there will be some minor changes to sql etc. that you may need to be wary of.

andrejs

5 Jun 2009, 6:58 PM
#26
edon12 avatar

edon12

New Zenner

Join Date:
Apr 2009
Posts:
9
Plugin Contributions:
0

Re: How To Add New Product Fields?

hi, i followed your directions and almost everything seems to be working great. Thank you for posting this info. I followed everything from your first post and now I have a field added and when I add a new product, the database updates appropriately for my new table and fields.

The problem I an running into is that the product page doesn't pull the new information from these fields into the page. It's there in the database, it's just that it doesn't pull into the page. The products_id's all match up and I can view it in phpMyAdmin. Even when I remove the php IF statement from the tpl_product_info_display.php page, to force anything to display, the field from the database doesn't show up, only the hard-coded text before that field.

Does anyone have any pointers on why this might be happening?

Thanks in advance for any help!

5 Jun 2009, 8:01 PM
#27
edon12 avatar

edon12

New Zenner

Join Date:
Apr 2009
Posts:
9
Plugin Contributions:
0

Re: How To Add New Product Fields?

Never mind the last post. I figured out the problem, I just made a small syntax error in the main_template_vars.php file.

Great thread though.

20 Jun 2009, 9:45 PM
#28
steveyork136 avatar

steveyork136

New Zenner

Join Date:
Nov 2005
Posts:
84
Plugin Contributions:
0

Re: How To Add New Product Fields?

thanks webego for putting this little guide together and all the others who contributed, its helped me a lot, but I'm stuck, 6 hours and lots of coffee and I'm missing something but I can't figure out what.

I started with a single extra field as in the guide, that worked so I added a second field, that worked so I added 20 fields but thats broken it.

It works fine on the public side, I've populate via phpmyadmin and it shows on the product page, so I've ruled out a database error.

But when it come to adding or amending a product it fails with the error

1054 Unknown column 'year_1985' in 'field list'
in:
[insert into products_extra_stuff (products_maker, products_ex_model, year_1985, year_1986, year_1987,.....

this happens from the product preview page, when I hit the update button, I can see the new field variables on the product preview page (putting in a php echo) so it seem the problem is on the update_product.php page.

here the added code for that page

////////////// MY ADDED FIELDS ////////////////////
$sql_data_array = array('products_maker' => zen_db_prepare_input($_POST['products_maker']),
'products_ex_model' => zen_db_prepare_input($_POST['products_ex_model']),
'year_1985' => zen_db_prepare_input($_POST['year_1985']),
'year_1986' => zen_db_prepare_input($_POST['year_1986']),
'year_1987' => zen_db_prepare_input($_POST['year_1987']),
'year_1988' => zen_db_prepare_input($_POST['year_1988']),
'year_1989' => zen_db_prepare_input($_POST['year_1989']),
'year_1990' => zen_db_prepare_input($_POST['year_1990']),
'year_1991' => zen_db_prepare_input($_POST['year_1991']),
'year_1992' => zen_db_prepare_input($_POST['year_1992']),
'year_1993' => zen_db_prepare_input($_POST['year_1993']),
'year_1994' => zen_db_prepare_input($_POST['year_1994']),
'year_1995' => zen_db_prepare_input($_POST['year_1995']),
'year_1996' => zen_db_prepare_input($_POST['year_1996']),
'year_1997' => zen_db_prepare_input($_POST['year_1997']),
'year_1998' => zen_db_prepare_input($_POST['year_1998']),
'year_1999' => zen_db_prepare_input($_POST['year_1999']),
'year_2000' => zen_db_prepare_input($_POST['year_2000']),
'year_2001' => zen_db_prepare_input($_POST['year_2001']),
'year_2002' => zen_db_prepare_input($_POST['year_2002']),
'year_2003' => zen_db_prepare_input($_POST['year_2003']),
'year_2004' => zen_db_prepare_input($_POST['year_2004']),
'year_2005' => zen_db_prepare_input($_POST['year_2005']),
'year_2006' => zen_db_prepare_input($_POST['year_2006']),
'year_2007' => zen_db_prepare_input($_POST['year_2007']),
'year_2008' => zen_db_prepare_input($_POST['year_2008']),
'year_2009' => zen_db_prepare_input($_POST['year_2009']),
'year_2010' => zen_db_prepare_input($_POST['year_2010']),
'year_2011' => zen_db_prepare_input($_POST['year_2011']),
'year_2012' => zen_db_prepare_input($_POST['year_2012']),
'year_2013' => zen_db_prepare_input($_POST['year_2013']),
'year_2014' => zen_db_prepare_input($_POST['year_2014']),
'year_all' => zen_db_prepare_input($_POST['year_all'])

  				);

if ($action == 'insert_product') {
$insert_sql_data = array('products_id' => $products_id);

$sql_data_array = array_merge($sql_data_array, $insert_sql_data);

zen_db_perform('products_extra_stuff', $sql_data_array);
} elseif ($action == 'update_product') {
zen_db_perform('products_extra_stuff', $sql_data_array, 'update', "products_id = '" . (int)$products_id . "'");
}
/////////////////////////////////////////////

can anyone advise me what I've missed.
thanks

28 Jun 2009, 10:52 PM
#29
ruthnis avatar

ruthnis

New Zenner

Join Date:
Jun 2007
Posts:
7
Plugin Contributions:
0

Re: How To Add New Product Fields?

Hi

I added 13 fields and everything worked fine.

When I deleted a product, it did not delete the record in the new table.

Can somebody give me the code for deletion too?

Thanks :clap:

22 Jul 2009, 12:25 AM
#30
dansicle avatar

dansicle

New Zenner

Join Date:
Jul 2009
Posts:
14
Plugin Contributions:
0

Re: How To Add New Product Fields?

That's an excellent question, so I'm just bumping this. Anyone want to tackle making sure the products from the new table are deleted when they're deleted from the products table?

Great thread!

22 Jul 2009, 10:14 AM
#31
webego avatar

webego

New Zenner

Join Date:
Oct 2008
Posts:
36
Plugin Contributions:
0

Re: How To Add New Product Fields?

Sorry I have not been back to post for a while (super busy) and thanks for all the comments. I hope some of the older replies have been resolved, if not let me know and I will see what I can do.

With regard to deleting records in the TABLE_PRODUCTS_EXTRA_STUFF table, I can't believe I forgot to include this functionality in the first place.

I have not tested the following code so if someone cares to try this out and let me know if it works that would be great.

  1. Open admin/includes/functions/general.php and search for 'function zen_remove_product' (line 1203 for me)
  2. At the end of that function and just after the following code:

$db->Execute("delete from " .
TABLE_PRODUCTS_DISCOUNT_QUANTITY . "
where products_id = '" . (int)$product_id . "'");

(line 1276 for me)

Add the following on a new line:

$db->Execute("delete from " .
TABLE_PRODUCTS_EXTRA_STUFF . "
where products_id = '" . (int)$product_id . "'");

Make sure you add this before the closing '}' of the function (line 1279 for me before the edit).

I hope this also helps you out.

24 Jul 2009, 1:40 AM
#32
maeve100 avatar

maeve100

New Zenner

Join Date:
Jul 2009
Posts:
12
Plugin Contributions:
0

Re: How To Add New Product Fields?

Hi there -

Has anyone come across this issue - or know what page I should look into for problems? The product display pages work fine, and I can manually enter values in the products_color database - but after these changes my "Update Products" from the Zen cart Admin is totally broke. I can enter in data for new and exsisting products - but when I hit update it goes to a blank screen with the Zen cart nav bars up top. I am thinking its the update_products.php file - but I have reverted it, copied over the snippet and it still doesn't work. Any ideas on what to look for?

Liz

24 Jul 2009, 4:20 AM
#33
ruthnis avatar

ruthnis

New Zenner

Join Date:
Jun 2007
Posts:
7
Plugin Contributions:
0

Re: How To Add New Product Fields?

Hi

The issue is not with the code that appears in this thread because it is working.

I assume that the problem is with the SQL script that updates the database.

The fact that you are getting a blank page is because there is an error.

You can configure php.ini differently so that you see the errors.

I would suggest that you check your definitions in admin/includes/modules/update_product.php
(article 6 in the explanation of the procedure).

Good Luck,
Ruth

24 Jul 2009, 5:16 PM
#34
maeve100 avatar

maeve100

New Zenner

Join Date:
Jul 2009
Posts:
12
Plugin Contributions:
0

Re: How To Add New Product Fields?

I am not sure what was causing this at all - but I tried copying over the code once more and it worked. There must have been a return, or an extra space somewhere in what I was doing. I am very glad to have these instructions though - thank you!

26 Jul 2009, 3:20 PM
#35
webego avatar

webego

New Zenner

Join Date:
Oct 2008
Posts:
36
Plugin Contributions:
0

Re: How To Add New Product Fields?

Has anybody tried out my delete code above?

27 Jul 2009, 8:53 AM
#36
dansicle avatar

dansicle

New Zenner

Join Date:
Jul 2009
Posts:
14
Plugin Contributions:
0

Re: How To Add New Product Fields?

Not yet, but I intend to very soon.

17 Aug 2009, 8:44 PM
#37
je2009 avatar

je2009

New Zenner

Join Date:
Jul 2009
Location:
Maryland
Posts:
65
Plugin Contributions:
0

Re: How To Add New Product Fields?

delia:

well, I don't know what's happening with our zen leaders so I've uploaded my mod to my website so that everyone can grab it now. Please, if anyone runs into problems, let me know!

The first extra field is now a textarea that can be used for embedding a YouTube video by the way.

Grab the zip file here

Enjoy!

Delia,

the link is broken, wanted to download your mod.

thanks,

JE

1 Sep 2009, 3:32 PM
#38
autoace avatar

autoace

Totally Zenned

Join Date:
Jun 2009
Posts:
618
Plugin Contributions:
0

Re: How To Add New Product Fields?

I am looking to add additional product data fields as well but also have Easy Populate CSV installed as well. Will this additional code process break Easy Populate CSV?

Thank you.

Thank you,
autoace

13 Sep 2009, 9:23 AM
#39
webego avatar

webego

New Zenner

Join Date:
Oct 2008
Posts:
36
Plugin Contributions:
0

Re: How To Add New Product Fields?

Sorry autoace, I don't use easypopulate so can't comment. If you do try the mods out though, please report back on your success or failure for the benefit of others using easypopulate.

Thanks

G

14 Sep 2009, 12:16 AM
#40
aliepinieks avatar

aliepinieks

Zen Follower

Join Date:
Jun 2009
Location:
Brisbane, QLD AUS
Posts:
209
Plugin Contributions:
0

Re: How To Add New Product Fields?

it won't break it, it simply ignores any fields that are not defined in the easypopulate.php file located under admin/includes.
to define these additional/custom fields, you could simply do a search for a similar type field in the aforementioned file, and then add the extra code (where relevant) after you've added your database fields of course. you need to ue a bit of common sense, but it worked for me making all the changes required (to easypopulate) in under 10min.

andrejs