Forums / Setting Up Categories, Products, Attributes / How-To: Add new Properties to your Products

How-To: Add new Properties to your Products

Views: 144,144

Results 141 to 160 of 272
17 Mar 2009, 7:19 AM
#141
dropbop avatar

dropbop

Zen Follower

Join Date:
Apr 2008
Location:
Athlone, Ireland
Posts:
177
Plugin Contributions:
1

How-To: Add new Properties to your Products

The step by step guide by the OP is very clear. There must be something you may have done wrong without realising.
Best thing to do is double check you have entered everything properly. for example...

The OP wrote

db manipulation
open the table "products" in your zencart-database and insert new rows at the end of the table called "products_guarantee" and "products_color"
ALTER TABLE zencart_products ADD products_guarantee INT NOT NULL , ADD products_color VARCHAR( 32 ) NOT NULL;

did you change the table names to suit your database, ie: ALTER TABLE zen_products............

Did you do as I said in my previous post.. adding the comma ","

In collect_info.php and preview_info.php, when you add the lines p.products_guarantee, p.products_color (or what ever you called them for your database) you need to make sure to add a comma at the end of the last line before you add the above lines.

I know, very simple things, but easy to miss too.

Im not great at explaining things, but hope it helps

DB

17 Mar 2009, 2:00 PM
#142
hovsepations avatar

hovsepations

New Zenner

Join Date:
Sep 2008
Location:
Toronto
Posts:
35
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

is there anyone who did this whole thing and worked for them???

because what i'm trying to do is to

1-add extra fields in my products table (which i was able to do)

2-add them to the admin section (which i was able to do)

3-show them on the product details page (worked too)

4-show them on the product listing page, that's when you click on a category name and lists all the products (can't do it yet) (HELP NEEDED!!!)

if anyone can find a solution for this or find a solution already please post it here, i'll be thankful.

thanks a lot.

17 Mar 2009, 7:20 PM
#143
dropbop avatar

dropbop

Zen Follower

Join Date:
Apr 2008
Location:
Athlone, Ireland
Posts:
177
Plugin Contributions:
1

Re: How-To: Add new Properties to your Products

Hi hovsepations,

I could actually do with something similar so I am going to have a go at it tonight, if I get it to work I will post here for you.

regards

DB

18 Mar 2009, 9:51 AM
#144
dropbop avatar

dropbop

Zen Follower

Join Date:
Apr 2008
Location:
Athlone, Ireland
Posts:
177
Plugin Contributions:
1

Re: How-To: Add new Properties to your Products

Could not figure it out, sorry.

18 Mar 2009, 8:01 PM
#145
yakbuttertea avatar

yakbuttertea

New Zenner

Join Date:
Feb 2009
Posts:
31
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

Ok, so I finally managed to display my new field 'products_botanical' that I added with the routine of crasy_chris. Thanks by the way!

But in order to show it in products_listing, I had to replace 'PRODUCT_LIST_BOTANICAL' by 8 in $define_list in main_template_vars. If I echo the size of column_list it returns only the 4 that are supposed to be displayed set in the admin section.
1- How can I change/add a column to column_list?

2- Where is 'PRODUCT_LIST_BOTANICAL' defined?

3- How can I change where that column would display?

Also, the sort through that column doesn't work, and now I am really lost...:frusty:

you can see my site at
practitioners.springwind.com

Thanks for any input on how to fix the issues.
Fred

20 Mar 2009, 3:59 PM
#146
yakbuttertea avatar

yakbuttertea

New Zenner

Join Date:
Feb 2009
Posts:
31
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

yakbuttertea:

Ok, so I finally managed to display my new field 'products_botanical' that I added with the routine of crasy_chris. Thanks by the way!

But in order to show it in products_listing, I had to replace 'PRODUCT_LIST_BOTANICAL' by 8 in $define_list in main_template_vars. If I echo the size of column_list it returns only the 4 that are supposed to be displayed set in the admin section.
1- How can I change/add a column to column_list?

2- Where is 'PRODUCT_LIST_BOTANICAL' defined?

3- How can I change where that column would display?

Also, the sort through that column doesn't work, and now I am really lost...:frusty:

you can see my site at
practitioners.springwind.com

Thanks for any input on how to fix the issues.
Fred
Ok, so maybe that will help someone like me that was having issues displaying their new fields:

  • If you follw the step describe around page 6-7-8 (don't remember sorrywhich page exactly) everything will be in place but not displaying. Don't panic, you have to define the constant PRODUCT_LIST_BOTANICAL somewhere and that is defined in the admin section. It tells the program that that column is the number 'x' to be displayed at the 'x' position. So once you define it it will magically appear... Well the way I did it is define it on /includes/module/pages/index/main_template_vars.php instead of putting 'PRODUCT_LIST_BOTANICAL' => PRODUCT_LIST_BOTANICAL, I did 'PRODUCT_LIST_BOTANICAL' => 8 and it worked. :happy:

  • Now I have an other question, how can we have the alpha filter working on the new field?

Thanks!

20 Mar 2009, 4:00 PM
#147
yakbuttertea avatar

yakbuttertea

New Zenner

Join Date:
Feb 2009
Posts:
31
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

hovsepations:

is there anyone who did this whole thing and worked for them???

because what i'm trying to do is to

1-add extra fields in my products table (which i was able to do)

2-add them to the admin section (which i was able to do)

3-show them on the product details page (worked too)

4-show them on the product listing page, that's when you click on a category name and lists all the products (can't do it yet) (HELP NEEDED!!!)

if anyone can find a solution for this or find a solution already please post it here, i'll be thankful.

thanks a lot.
Look at my posting maybe that is your answer...

20 Mar 2009, 5:27 PM
#148
hovsepations avatar

hovsepations

New Zenner

Join Date:
Sep 2008
Location:
Toronto
Posts:
35
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

thanks yakbuttertea,
i'm gonna try it and see how it works for me.

i'll let you know:clap:

20 Mar 2009, 5:31 PM
#149
j_star avatar

j_star

New Zenner

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

Re: How-To: Add new Properties to your Products

I'm selling computer equipment, which has very many different properties (for instance size, how much ram, cpu etc.), so I almost need to add 50 different ones that only show when filled in admin console.

But before I begin I wondered if it’s smart to do it this way, if not what do you advice?

24 Mar 2009, 7:07 PM
#150
yakbuttertea avatar

yakbuttertea

New Zenner

Join Date:
Feb 2009
Posts:
31
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

Does someone know how to work with alpha filter?I am trying to have my new field sorted by the alpha filter. So far, the filter sort only by the Item column.How can we add an other filter or choose which column the filter will work on?

30 Mar 2009, 3:04 PM
#151
webego avatar

webego

New Zenner

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

Re: How-To: Add new Properties to your Products

I have posted a mix of the OP solution on this thread and the one by zskiman (mid thread) plus my own additions which allows the creation of new product fields, held in a separate table and declared so they can be inserted into the page in the same manner as existing fields.

http://www.zen-cart.com/forum/showthread.php?t=120523

Hopefully of use to someone.

G

6 May 2009, 8:11 PM
#152
miriam_t avatar

miriam_t

New Zenner

Join Date:
May 2007
Posts:
38
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

Does anybody know how to add an additional IMAGE field to the product table?

I need this to display a special image at a place other than main image or additional images.

I managed to add various fields which all show up fine both in admin and catalog but the newly created image field isn't shown nor is the file-name in the database as it should be. I simply copied some parts from the main image for this new image field. It is displayed on the preview_info.php but gets lost on its way to be stored.

Can someone give a hint on this issue? Thanks in advance!

3 Aug 2009, 4:50 PM
#153
gamesmart avatar

gamesmart

New Zenner

Join Date:
Nov 2008
Posts:
28
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

I've added without problems many new fileds in my products page like this:

hhttp://www.dvdmart.it/shop/007-il-mondo-non-basta-p-91410.html

now i'm trying to add many of these fiels in products_all listing, featured, new etc.

my work:

includes/modules/product_listing.php

near line 30:

case 'PRODUCT_LIST_NAME':
$lc_text = TABLE_HEADING_PRODUCTS;
$lc_align = '';
$zc_col_count_description++;
break;

case 'PRODUCT_LIST_MYFIELD':
$lc_text = TABLE_HEADING_MYFIELD;
$lc_align = '';
$zc_col_count_description++;
break;

near line 100:

case 'PRODUCT_LIST_MODEL':
$lc_align = '';
$lc_text = $listing->fields['products_model'];
break;

    case 'PRODUCT_LIST_MYFIELD':
    $lc_align = '';
    $lc_text = $listing->fields['products_myfieldsqlname'];
    break;

includes/modules/pages/index/main_template_vars.php

near line 136:

// create column list
$define_list = array(
'PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL,
'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME,
'PRODUCT_LIST_MYFIELD' => PRODUCT_LIST_MYFIELD,

near line 163:

switch ($column_list[$i])
{
case 'PRODUCT_LIST_MODEL':
$select_column_list .= 'p.products_model, ';
break;
case 'PRODUCT_LIST_MYFIELD':
$select_column_list .= 'products_myfieldsqlname, ';
break;

includes/index_filters/default_filter.php

near line 28, 43, 58, 73:

$listing_sql = "select " . $select_column_list . " p.products_id, p.products_myfieldsqlname,

near line 117:

case 'PRODUCT_LIST_NAME':
$listing_sql .= "pd.products_name " . ($sort_order == 'd' ? 'desc' : '');
break;
case 'PRODUCT_LIST_MANUFACTURER':
$listing_sql .= "m.manufacturers_name " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
break;
case 'PRODUCT_LIST_MYFIELD':
$listing_sql .= "p.products_myfieldsqlname" . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
break;

near line 122:

case 'PRODUCT_LIST_MANUFACTURER':
$listing_sql .= "m.manufacturers_name " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
break;
case 'PRODUCT_LIST_MYFIELD':
$listing_sql .= "p.products_myfieldsqlname" . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
break;

includes/modules/template/MYTEMPLATE/template/tpl_modules_products_all_listing.php

near line 42:

    if (PRODUCT_ALL_LIST_MODEL != '0' and zen_get_show_product_switch($products_all->fields['products_id'], 'model')) {
    $display_products_model = '<b>' . TEXT_PRODUCTS_MODEL . '</b>' . $products_all->fields['products_model'] . str_repeat('<br clear="all" />', substr(PRODUCT_ALL_LIST_MODEL, 3, 1));
  } else {
    $display_products_model = '';
  }
    if (PRODUCT_ALL_LIST_MYFIELD != '0' and zen_get_show_product_switch($products_all->fields['products_myfieldsqlname'], 'myfield')) {
    $display_products_myfield = '<b>' . TEXT_PRODUCTS_MYFIELD . '</b>' . $products_all->fields['products_myfieldsqlname'] . str_repeat('<br clear="all" />', substr(PRODUCT_ALL_MYFIELD, 3, 1));
 } else {
  $display_products_myfield = '';
  }          

near line 141:

    if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_MYFIELD') {
                echo $display_products_model;
              }
              if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_LIST_MYFIELD') {
                echo $display_products_myfield;
              }      

near line 177:

    if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_LIST_MODEL') {
                echo $display_products_model;
              }
              if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_LIST_MYFIELD') {
                echo $display_products_myfield;
              }

includes/languages/MYTEMPLATE/english etc

define('TEXT_PRODUCTS_MYFIELD', 'My extra products field');

in my database i've added:

INSERT INTO configuration (configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES (1200, 'Show my myfield', 'PRODUCT_ALL_LIST_MYFIELD', '2506', 'bla bla bla', 21, 13, NULL, '2006-07-05 13:59:40', NULL, NULL);

Nothing appear here:

http://www.dvdmart.it/shop/products_all.html

whats wrong?
Thanks!

Max

3 Aug 2009, 5:17 PM
#154
gamesmart avatar

gamesmart

New Zenner

Join Date:
Nov 2008
Posts:
28
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

i can't modify my last post, on

near line 141:

if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_MYFIELD') {
echo $display_products_model;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_LIST_MYFIELD') {
echo $display_products_myfield;
}

right is

near line 141:

if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_MODEL') {
echo $display_products_model;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_LIST_MYFIELD') {
echo $display_products_myfield;
}

thanks! :P

Max

10 Aug 2009, 1:49 PM
#155
gamesmart avatar

gamesmart

New Zenner

Join Date:
Nov 2008
Posts:
28
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

Resolved, ALONE. :dontgetit

Max

10 Sep 2009, 10:35 AM
#156
shen avatar

shen

New Zenner

Join Date:
Nov 2007
Posts:
30
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

I tried using this but didn't get the desired results. On further delving I believe the original how-to is mistaken, and I'm not sure why it works for so many others.

I'm not a professional coder but I was able to fix it by replicating the way products_weight is handled. (I am adding height, length and width properties.)

I'm not sure if all the following additions are necessary, but they worked for me. The main problem is that copy_to_confirm.php was not modified in this how-to. All additions based on a property product_height.

  1. update_product.php (in /admin/includes/modules/)
    a) around line 30, ADD:
    $tmp_value = zen_db_prepare_input($_POST['products_height']);
    $products_height = (!zen_not_null($tmp_value) || $tmp_value=='' || $tmp_value == 0) ? 0 : $tmp_value;

b) around line 40 ($sql_data_array = ....), ADD:

'products_height' => $products_height,
  1. copy_to_confirm.php (in /admin/includes/modules/)
    a) around line 37 ($product = $db->Execute...) ADD:

, products_height


 b) around line 52 ADD:
        $tmp_value = zen_db_input($product->fields['products_height']);
        $products_height = (!zen_not_null($tmp_value) || $tmp_value=='' || $tmp_value == 0) ? 0 : $tmp_value;

 c) around line 62 ($db->Execute("insert into " . TABLE_PRODUCTS . "....)  ADD:

, products_height


 d) around line 79 (continuation of last statement) ADD
                              '" . $products_height . "',

I'm pretty sure these last two need to have the fields in the correct order that they appear in the table.

OK!  Now I can enter the new properties and they actually get entered into the database!!!   :clap:
10 Sep 2009, 12:02 PM
#157
webego avatar

webego

New Zenner

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

Re: How-To: Add new Properties to your Products

Hi shen,

I have made a modified version of the steps from this thread here which has worked for many. Note I have also added a bit here to ensure the extra product data is deleted when deleting a product.

G

30 Sep 2009, 2:52 AM
#158
kismetdesign avatar

kismetdesign

Zen Follower

Join Date:
May 2009
Location:
Junction City, Oregon
Posts:
315
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

I installed a new text field and got it right the first time. Woo Hoo! :clap::clap::clap:

One trivial question... on the admin side, when I fill out the information, my new text field shows up at the bottom of my product listing page. Where do I need to go to move it up, right under my title?

I already moved it up on my product info page that people can see, but on the admin side it would be nice to have the subtitle field I just created go directly under the title field.

Thanks!

KD

30 Sep 2009, 9:37 AM
#159
janekbar5 avatar

janekbar5

New Zenner

Join Date:
Jul 2006
Posts:
16
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

Hi
Look at the 1 page of this post it will be in
edit 'collect_info.php' (in /admin/includes/modules/product/),
edit 'preview_info.php' (in /admin/includes/modules/product/) or
edit 'update_product.php' (in /admin/includes/modules/)
don't remember now.

6 Oct 2009, 7:22 PM
#160
kismetdesign avatar

kismetdesign

Zen Follower

Join Date:
May 2009
Location:
Junction City, Oregon
Posts:
315
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

It doesn't say specifically which file controls where the text field appears on the admin side when filling out product details. With 3 different files and 5-6 different edits, I don't want to mess this up before I start. Anyone else have an idea of which file it would be, and where I would look to re-order the fields?

Thanks,

KD :smile: