Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2009
    Posts
    30
    Plugin Contributions
    0

    Default Showing additional fields in product listing

    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/showth...+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!

  2. #2
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Showing additional fields in product listing

    "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.

  3. #3
    Join Date
    Jun 2009
    Posts
    30
    Plugin Contributions
    0

    Default Re: Showing additional fields in product listing

    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.

  4. #4
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,296
    Plugin Contributions
    22

    Default Re: Showing additional fields in product listing

    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

 

 

Similar Threads

  1. Additional Product Fields
    By Kamino84 in forum Customization from the Admin
    Replies: 9
    Last Post: 16 Jun 2011, 08:40 PM
  2. Additional Product Fields
    By schwarzes in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 8 Aug 2010, 07:05 PM
  3. Alignment issue on product listing with additional fields
    By Meers007 in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 21 Aug 2009, 10:12 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR