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

How To Add New Product Fields?

Views: 83,922

Results 81 to 100 of 159
12 Nov 2009, 6:54 PM
#81
stitchnkitty avatar

stitchnkitty

Totally Zenned

Join Date:
Jun 2009
Location:
Des Moines, Iowa USA
Posts:
618
Plugin Contributions:
0

How To Add New Product Fields?

:clap::clap::clap::clap::clap:!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

SUCCESS!

Now I know this is simple but how do I make the little box bigger.
My type is varchar with a length of 42 but the box is no more than 3 spaces???

TIA

14 Nov 2009, 2:52 PM
#82
stitchnkitty avatar

stitchnkitty

Totally Zenned

Join Date:
Jun 2009
Location:
Des Moines, Iowa USA
Posts:
618
Plugin Contributions:
0

Re: How To Add New Product Fields?

OK I broke it again I really need some advise!!!
I was trying to expand my littlle field box - when I adjusted the
admin/includes/modules/product/collect_info.php

changed as suggested in the top posting: Where my table is products_skill_type and my field is products_skilltype

p.products_discount_type, p.products_discount_type_from,

                                 p.products_price_sorter, p.master_categories_id, pdex.products_skilltype

from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " .
TABLE_PRODUCTS_SKILL_TYPE . " pdex
where p.products_id = '" . (int)$_GET['pID'] . "'
and p.products_id = pd.products_id and p.products_id = pdex.products_id

                          and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'");

ERROR

1146 Table 'snf.products_skilltype' doesn't exist
in:
[select pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_virtual, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id, p.products_quantity_order_min, p.products_quantity_order_units, p.products_priced_by_attribute, p.product_is_free, p.product_is_call, p.products_quantity_mixed, p.product_is_always_free_shipping, p.products_qty_box_status, p.products_quantity_order_max, p.products_sort_order, p.products_discount_type, p.products_discount_type_from, p.products_price_sorter, p.master_categories_id, pdex.products_skilltype from products p, products_description pd, products_skilltype pdex where p.products_id = '22' and p.products_id = pd.products_id and p.products_id = pdex.products_id and pd.language_id = '1']

14 Nov 2009, 10:59 PM
#83
webego avatar

webego

New Zenner

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

Re: How To Add New Product Fields?

If as you say "table is products_skill_type and my field is products_skilltype" is true then looking at the error I would suggest that maybe you table definition (in step 2 of my original instructions) is wrong.

It is probably currently:

define('TABLE_PRODUCTS_SKILL_TYPE', DB_PREFIX . 'products_skilltype');

but should be:

define('TABLE_PRODUCTS_SKILL_TYPE', DB_PREFIX . 'products_skill_type');

Hope that helps.

15 Nov 2009, 2:41 PM
#84
stitchnkitty avatar

stitchnkitty

Totally Zenned

Join Date:
Jun 2009
Location:
Des Moines, Iowa USA
Posts:
618
Plugin Contributions:
0

Re: How To Add New Product Fields?

And it was but I am still getting an error so I started over and tripled checked everything and :

1.table is products_skill_type with field of products_skill type

  • type is varchar length 42 and collation latin1_general_ci

define('TABLE_PRODUCTS', DB_PREFIX . 'products');
define('TABLE_PRODUCTS_SKILL_TYPE', DB_PREFIX . 'products_skill_type');

define('TABLE_PRODUCT_TYPES', DB_PREFIX . 'product_types');
3.
p.products_sort_order, pdex.products_skilltype

                        from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd,".
                        TABLE_PRODUCTS_SKILL_TYPE."pdex
                           where p.products_id = pd.products_id
                           and p.products_id = pdex.products_id
  $pInfo = new objectInfo($product->fields);
  $products_image_name = $pInfo->products_image;

line12
'master_categories_id' => '',
'products_skilltype'=> ''
);
line60;
p.products_price_sorter, p.master_categories_id, pdex.products_skilltype
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " .
TABLE_PRODUCTS_SKILL_TYPE . " pdex
where p.products_id = '" . (int)$_GET['pID'] . "'
and p.products_id = pd.products_id and p.products_id = pdex.products_id

                          and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'");

line 305

<!-- BOF - Additional field added --> <tr> <td class="main"><?php echo 'Skill Type'; ?></td> <td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '13') . ' ' . zen_draw_input_field('products_skilltype', $pInfo->products_skilltype, zen_set_field_length (TABLE_PRODUCTS_SKILL_TYPE, 'products_skilltype')); ?></td> </tr> <!-- EOF - Additional field added -->

line 153
////////////// MY ADDED FIELDS ////////////////////
$sql_data_array = array('products_skilltype' => zen_db_prepare_input($_POST['products_skilltype']));

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(TABLE_PRODUCTS_SKILL_TYPE, $sql_data_array);
} elseif ($action == 'update_product') {
zen_db_perform(TABLE_PRODUCTS_SKILL_TYPE, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "'");
}
/////////////////////////////////////////////

line57
p.products_discount_type, p.products_discount_type_from,
p.products_sort_order, p.products_price_sorter, pdex.products_skilltype
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd,".
TABLE_PRODUCTS_SKILL_TYPE . " pdex
where p.products_status = '1'
and p.products_id = '" . (int)$_GET['products_id'] . "'
and pd.products_id = p.products_id and p.products_id = pdex.products_id

       and    pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";

line102
$products_skilltype = $product_info->fields['products_skilltype'];

line55

<!--bof Product Skill Type --> <?php if ($products_skilltype != '') { ?> <div id="productSkillType" class="productGeneral"><strong>Skill Type: </strong><?php echo $products_skilltype; ?></div> <?php } ?> <!--eof Product Skill Type -->

I have starred at this for mega hours checked for errors - used copy paste when ever I could to ellimate charactor erros.

Admin says:
1054 Unknown column 'pdex.products_id' in 'where clause'
in:
[select pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_virtual, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id, p.products_quantity_order_min, p.products_quantity_order_units, p.products_priced_by_attribute, p.product_is_free, p.product_is_call, p.products_quantity_mixed, p.product_is_always_free_shipping, p.products_qty_box_status, p.products_quantity_order_max, p.products_sort_order, p.products_discount_type, p.products_discount_type_from, p.products_price_sorter, p.master_categories_id, pdex.products_skilltype from products p, products_description pd, products_skill_type pdex where p.products_id = '22' and p.products_id = pd.products_id and p.products_id = pdex.products_id and pd.language_id = '1']
If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you left no blank fields.

Also I have seen errors on my pages that is caused by this - such as in my shopping cart there is a phrase that shows up *and *if the cart is empty - then the there is product images if you click on the product images a array of coding comes up.

www...stitchnframeonline...com/snfcart
is my site -
I have lost alot of hair on this one any ideas would be appriciated.
TIA

16 Nov 2009, 1:18 PM
#85
webego avatar

webego

New Zenner

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

Re: How To Add New Product Fields?

Hi,

Okay well looking at your code, it appears you are missing a space between the quote and pdex in step 3.

You have:
TABLE_PRODUCTS_SKILL_TYPE."pdex

Should be:
TABLE_PRODUCTS_SKILL_TYPE." pdex

It also appears that you are missing the end of that query (unless this is just how you have pasted your example). It should be as follows:

p.products_sort_order, pdex.products_skilltype
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_SKILL_TYPE . " pdex
where p.products_id = pd.products_id and p.products_id = pdex.products_id
and p.products_id = '" . (int)$_GET['pID'] . "'");

$pInfo = new objectInfo($product->fields);
$products_image_name = $pInfo->products_image;

The rest of your code looks okay. Let me know how you get on with the above.

17 Nov 2009, 1:27 PM
#86
stitchnkitty avatar

stitchnkitty

Totally Zenned

Join Date:
Jun 2009
Location:
Des Moines, Iowa USA
Posts:
618
Plugin Contributions:
0

Re: How To Add New Product Fields?

OK I have c&p your suggestion and this is the error

step 3
$product = $db->Execute("select p.products_id, pd.language_id, pd.products_name,
pd.products_description, pd.products_url, p.products_quantity,
p.products_model, p.products_image, p.products_price, p.products_virtual,
p.products_weight, p.products_date_added, p.products_last_modified,
p.products_date_available, p.products_status, p.manufacturers_id,
p.products_quantity_order_min, p.products_quantity_order_units, p.products_priced_by_attribute,
p.product_is_free, p.product_is_call, p.products_quantity_mixed,
p.product_is_always_free_shipping, p.products_qty_box_status, p.products_quantity_order_max,
p.products_sort_order, pdex.products_skilltype
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_SKILL_TYPE . " pdex
where p.products_id = pd.products_id and p.products_id = pdex.products_id
and p.products_id = '" . (int)$_GET['pID'] . "'");

  $pInfo = new objectInfo($product->fields);
  $products_image_name = $pInfo->products_image;
}

1054 Unknown column 'pdex.products_id' in 'where clause'
in:
[select pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_virtual, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id, p.products_quantity_order_min, p.products_quantity_order_units, p.products_priced_by_attribute, p.product_is_free, p.product_is_call, p.products_quantity_mixed, p.product_is_always_free_shipping, p.products_qty_box_status, p.products_quantity_order_max, p.products_sort_order, p.products_discount_type, p.products_discount_type_from, p.products_price_sorter, p.master_categories_id, pdex.products_skilltype from products p, products_description pd, products_skill_type pdex where p.products_id = '22' and p.products_id = pd.products_id and p.products_id = pdex.products_id and pd.language_id = '1']
If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you left no blank fields.

All of my work at this time is on my computer - if it is of any help I BU my DB and upload what I have.

17 Nov 2009, 4:12 PM
#87
webego avatar

webego

New Zenner

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

Re: How To Add New Product Fields?

Might be a stupid question but you do have a products_id column in the products_skill_type table right?

I will PM you my email and if you wish you can send the db and I'll take a look at it. If you do, could you also send copies of the files you edited when following all the steps.

17 Nov 2009, 4:45 PM
#88
stitchnkitty avatar

stitchnkitty

Totally Zenned

Join Date:
Jun 2009
Location:
Des Moines, Iowa USA
Posts:
618
Plugin Contributions:
0

Re: How To Add New Product Fields?

The answer to your Q? is no i did not so that was stupid of mee - it says right there!
I have the product page now but with these warnings:
And have lost my shopping cart product page on my computer site - it is white so there has to be a error somewhere - I will look for that is you would have a suggestion on this error.

Warning: reset() [function.reset]: Passed variable is not an array or object in
admin\includes\classes\object_info.php on line 29

Warning: Variable passed to each() is not an array or object in
admin\includes\classes\object_info.php on line 30

17 Nov 2009, 4:49 PM
#89
stitchnkitty avatar

stitchnkitty

Totally Zenned

Join Date:
Jun 2009
Location:
Des Moines, Iowa USA
Posts:
618
Plugin Contributions:
0

Re: How To Add New Product Fields?

OK I viewing this in a preexisting item and not a new item - I have made note on the correction posts on deleting and the ont on #43 and will address this when I get this ok.

So would this be the cause of the warnings?

17 Nov 2009, 4:52 PM
#90
webego avatar

webego

New Zenner

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

Re: How To Add New Product Fields?

Yep, probably the reason for the warnings. You just need to follow those extra steps to populate the existing products into the new table.

Let me know how you get on.

18 Nov 2009, 2:13 PM
#91
stitchnkitty avatar

stitchnkitty

Totally Zenned

Join Date:
Jun 2009
Location:
Des Moines, Iowa USA
Posts:
618
Plugin Contributions:
0

Re: How To Add New Product Fields?

I THINK I have success -
Will know conpletely when I start to work in it - So again a tenative:clap::clap::clap:
I so appriciate the time you have donated to this( and probably other) threads. this is an important aspect that has been so helpful.

I do have one tiny glitch - probably is not hurting the program but it looks weird -

www....stitchnframonline...com/snfcart

kit
crewel
at the middle of the page i must have put in some sort of note to keep track of things and of course not really knowing what I am doing(sometimes it is dangerous) anyway it is showning up.

I have foxfire WebDev but have been unable to find the wordage. Also did a MS search on my computer using the wordage but had no luck finding it - i am assuming that MS search really does not look for things like that.
Again TY.

18 Nov 2009, 2:29 PM
#92
webego avatar

webego

New Zenner

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

Re: How To Add New Product Fields?

Glad to hear things look like they are sorted and you are most welcome to the help.

You will probably be able to use Developers Tool Kit to find your text. If you login to your admin then from the Tools menu select Developers Tool Kit. Then in the 'Look-up in all files' section at the bottom of the page type in some or all of the text you wish to search for and select 'All Files - Catalog/Admin' from the drop down list. That should list any files with matching text.

18 Nov 2009, 3:05 PM
#93
stitchnkitty avatar

stitchnkitty

Totally Zenned

Join Date:
Jun 2009
Location:
Des Moines, Iowa USA
Posts:
618
Plugin Contributions:
0

Re: How To Add New Product Fields?

Worked like a charm!

6 Dec 2009, 8:51 PM
#94
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: How To Add New Product Fields?

greengreetings:

I have a question. I followed all of the steps in the first post and when I go to a product in categories I receive this message:

Warning: reset() [function.reset]: Passed variable is not an array or object in /usr/www/users/deleted for privacy/catalog/deleted for privacy/includes/classes/object_info.php on line 29

Warning: Variable passed to each() is not an array or object in /usr/www/users/deleted for privacy/catalog/deleted for privacy/includes/classes/object_info.php on line 30
Product in Category: "Cards"

I don't know what that means nor what I should do. Any suggestions?

Hello Greengreetings,

I am getting the same message. In my case it apeared after modifying my code from one to four extra fields. While i already hade modified multiple products with the first extra field.
The message has somthing to do with the product ID's in the sdql table. After adding enough new products with four extra fields the message disapears. :frusty:

29 Dec 2009, 6:04 AM
#95
mrzhao avatar

mrzhao

New Zenner

Join Date:
Oct 2009
Posts:
2
Plugin Contributions:
0

Re: How To Add New Product Fields?

webego,thank you very much!

I have added 115 fields to my products successfully,just add my code very carefully according to what webego post.

9 Jan 2010, 1:47 PM
#96
steveyork136 avatar

steveyork136

New Zenner

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

Re: How To Add New Product Fields?

Thanks for getting this going webego it helps me a lot, hopefully I can give a little back.

This was working fine for me until I tried to copy a product but I reliased that copying a product doesn't add an extra row in the added fields table for the newly copied product. As I use copy product alot I though I'd try to code a fix. So here goes.

I've continued the original example using product_colour as the added field.

I would be pleased if someone from the zen team can cast their eye over this to see if the code is ok, it works but there may be a better way of doing it.

As always backup and test before you try this.

Open admin/includes/modules/copy_to_confirm.php

find (line 35 for me)

$product = $db->Execute("select products_type, products_quantity, products_model, products_image,
products_price, products_virtual, products_date_available, products_weight,
products_tax_class_id, manufacturers_id,
products_quantity_order_min, products_quantity_order_units, products_priced_by_attribute,
product_is_free, product_is_call, products_quantity_mixed,
product_is_always_free_shipping, products_qty_box_status, products_quantity_order_max, products_sort_order,
products_price_sorter, master_categories_id
from " . TABLE_PRODUCTS . "
where products_id = '" . (int)$products_id . "'");

replace with

$product = $db->Execute("select p.products_type, p.products_quantity, p.products_model, p.products_image,
p.products_price, p.products_virtual, p.products_date_available, p.products_weight,
p.products_tax_class_id, p.manufacturers_id,
p.products_quantity_order_min, p.products_quantity_order_units, p.products_priced_by_attribute,
p.product_is_free, p.product_is_call, p.products_quantity_mixed,
p.product_is_always_free_shipping, p.products_qty_box_status, p.products_quantity_order_max, p.products_sort_order,
p.products_price_sorter, p.master_categories_id,
pdex.products_colour,
from " . TABLE_PRODUCTS . " p, " . TABLE_ADDED_FIELDS." pdex
where p.products_id = '" . (int)$products_id . "'
and pdex.products_id = '" . (int)$products_id . "'");

Then after (line 109)

$db->Execute("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . "
(products_id, categories_id)
values ('" . (int)$dup_products_id . "', '" . (int)$categories_id . "')");
$products_id = $dup_products_id;
$description->MoveNext();

add

// added fields////////
$db->Execute("insert into " . TABLE_ADDED_FIELDS . "
(products_id, products_colour )
values ('" . (int)$dup_products_id ."', '" . zen_db_input($product->fields['products_colour']) . "' )");
// added fields////////

Sorry I can't seem to add source tag only quote, but you get my meaning :oops:

5 Mar 2010, 2:20 PM
#97
hogo avatar

hogo

New Zenner

Join Date:
Mar 2010
Posts:
14
Plugin Contributions:
0

Re: How To Add New Product Fields?

Hi,

I am trying to add a field do product description as described in guide at the begining of this topic. I have encountered some problems though. When I want to edit product, all data is blank and I need to insert all data from the begining, as in entering new product. I found this is related to 4th point of the guide. I have checked at least 10 times if everything I added is done properly, and I found no error.

This is how it looks:

p.products_price_sorter, p.master_categories_id, pdex.products_class
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " .
TABLE_PRODUCTS_EXTRA_DATA . " pdex
where p.products_id = '" . (int)$_GET['pID'] . "'
and p.products_id = pd.products_id
and p.products_id = pdex.products_id

when I delete the changes from this section, everything works fine again.

Please help, because I'm stuck.

rgds
HoGo

8 Apr 2010, 1:07 AM
#98
pamcc avatar

pamcc

New Zenner

Join Date:
Aug 2009
Posts:
16
Plugin Contributions:
0

Re: How To Add New Product Fields?

Hi. Thanks for posting this.

I have an error though...

Warning: reset() [function.reset]: Passed variable is not an array or object in /....../object_info.php on line 29

Warning: Variable passed to each() is not an array or object in /...../object_info.php on line 30

27 Apr 2010, 6:56 PM
#99
llynix avatar

llynix

Zen Follower

Join Date:
Jul 2009
Location:
Texas
Posts:
210
Plugin Contributions:
0

Re: How To Add New Product Fields?

steveyork136, applied your code and it fixes the copy / duplicate item function perfectly. Thanks for saving me some time.

Last two posts relate to this problem. Apply steveyork's fix and both should be solved.

Anthony

DentalPlanet Designed/Administrated by Falls Geek

3 Jun 2010, 9:00 AM
#100
lingray avatar

lingray

New Zenner

Join Date:
Aug 2009
Posts:
15
Plugin Contributions:
0

Re: How To Add New Product Fields?

Thanks alot for the post, I have managed to create about 10 new fields with no problems :). The time that was taken in writing this post is greatly appreciated.

What I'd like to do now is make the new fields searchable in the header of my site (via a dropdown list), does anybody know of a easy way to achieve this? Also, does zen cart have any function built in for sanitizing user input or should I write this myself?

Thanks