If this is your first visit, check our documentation. To post, register or login.
Forums / Setting Up Your Zen Cart Products / Setting Up Categories, Products, Attributes / Showing additional fields in product listing

Showing additional fields in product listing

Locked

Started by kbascombe on 15 Apr 2010, 2:04 AM · Views: 1,560

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
15 Apr 2010, 2:04 AM
#1
kbascombe avatar

kbascombe

New Zenner

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

Post #1 by kbascombe

Hi everyone,

Sorry, I know there are other threads addressing how to show your additional product fields in the product listing page, but I can't seem to get it to work for me. And the other threads seem to be years old.

I've followed the instructions in post #79 on this thread

http://www.zen-cart.com/forum/showthread.php?t=57924&highlight=custom+fields&page=8

I understand a tiny bit of php so I can follow the instructions but I don't really know the logic or what these modifications do.

So to summarize, this is what I've done... (with the additional field being metal type)

1. I've defined the table heading in the language files

File -includes/languages/english/index.php

define('TABLE_HEADING_PRICE', 'Price');
define('TABLE_HEADING_WEIGHT', 'Weight');
define('TABLE_HEADING_METAL_TYPE', 'Metal Type');

2. Setting up the case for something...?

File -includes/modules/product_listing.php

case 'PRODUCT_LIST_MODEL':
$lc_text = TABLE_HEADING_MODEL;
$lc_align = '';
$zc_col_count_description++;
break;
case 'PRODUCT_LIST_METAL_TYPE':
$lc_text = TABLE_HEADING_METAL_TYPE;
$lc_align = '';
$zc_col_count_description++;
break;

and the same further down the same file...

case 'PRODUCT_LIST_QUANTITY':
$lc_align = 'right';
$lc_text = $listing->fields['products_quantity'];
break;
case 'PRODUCT_LIST_METAL_TYPE':
$lc_align = 'right';
$lc_text = $listing->fields['products_metal_type'];
break;

(where it says $listing->fields['products_metal_type'] is the products_metal_type supposed to be my field name that I set up in the database? because the actual field name is just 'metal_type' and I've tried it both ways but neither seems to work)

3. Adding the fields to the sql query

File - includes/index_filters/default_filter.php

$listing_sql = "select " . $select_column_list . " p.products_id, p.products_type, p.manufacturers_id, p.products_price, p.products_tax_class_id, pd.products_description, IF(s.status = 1, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status = 1,
s.specials_new_products_price, p.products_price) as final_price, p.products_sort_order, p.product_is_call, p.product_is_always_free_shipping,
p.products_qty_box_status, p.products_metal_type

^ There are 4 blocks with that query in this file which I changed.

and then further down the same file

case 'PRODUCT_LIST_QUANTITY':
$listing_sql .= "p.products_quantity " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
break;
case 'PRODUCT_LIST_IMAGE':
$listing_sql .= "pd.products_name";
break;
case 'PRODUCT_LIST_METAL_TYPE':
$listing_sql .= "p.products_metal_type " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
break;

4. Displaying the fields in the products listing page?

File - includes/modules/pages/index/main_template_vars.php

$define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL,
'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME,
'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER,
'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE,
'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY,
'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT,
'PRODUCT_LIST_METAL_TYPE' => PRODUCT_LIST_METAL_TYPE,

and further down same file...

case 'PRODUCT_LIST_MODEL':
$select_column_list .= 'p.products_model, ';
break;
case 'PRODUCT_LIST_NAME':
$select_column_list .= 'pd.products_name, ';
break;
case 'PRODUCT_LIST_MANUFACTURER':
$select_column_list .= 'm.manufacturers_name, ';
break;
case 'PRODUCT_LIST_QUANTITY':
$select_column_list .= 'p.products_quantity, ';
break;
case 'PRODUCT_LIST_IMAGE':
$select_column_list .= 'p.products_image, ';
break;
case 'PRODUCT_LIST_METAL_TYPE':
$select_column_list .= 'p.products_metal_type, ';
break;

Sorry I haven't used line numbers but my line numbers seemed to be different from those in the original post I followed.

So after I've modified all those files above, the field Metal Type still doesn't show up on my product listing page.

Is there something I'm missing?

As always any help or shove in the right direction would be helpful.

Thanks!

15 Apr 2010, 2:11 AM
#2
gjh42 avatar

gjh42

Black Belt

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

Post #2 by gjh42

"is the products_metal_type supposed to be my field name that I set up in the database? because the actual field name is just 'metal_type' "

If the db field name is metal_type, you need to use that in the SQL query.
Then when the results of the query are loaded into an array, the array element can be named products_metal_type.

15 Apr 2010, 2:25 AM
#3
kbascombe avatar

kbascombe

New Zenner

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

Post #3 by kbascombe

Ok, I've changed the SQL query to pull the 'metal_type' field but kept all the other files referencing it as 'products_metal_type'... is that right?

It didn't change anything with regards to showing the field in the product listing page.

My client is using windows hosting... would this have any effect? I've heard windows hosting causes problems all the time.

26 Apr 2010, 3:36 PM
#4
delia avatar

delia

Totally Zenned

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

Post #4 by delia

There were more instructions about changes in the main_template_vars.php file that you didn't list above. Did you ever get this working?

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