Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15
  1. #11
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: custom product field

    Just looked at it and the splitPageResults function takes the SQL query as one of its arguments, so in your case you would have to modify the $listing_sql variable used in product_listing.php:
    PHP Code:
    $listing_split = new splitPageResults($listing_sqlMAX_DISPLAY_PRODUCTS_LISTING'p.products_id''page'); 
    Since product_listing.php does not build this variable, you need to use the Developers Toolkit to find where it is built for this purpose.

    /includes/index_filters/default_filter.php

    looks like the place. There are a number of different versions of $listing_sql built there, so we'll have to find the right one.
    Last edited by gjh42; 23 Nov 2008 at 05:40 PM.

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

    Default Re: custom product field

    In default_filter.php
    it looks like you would add your
    p.products_delivery (assuming it is in the products table)
    to the "select" list in line 27:
    PHP Code:
    // We are asked to show only a specific category
          
    $listing_sql "select " $select_column_list " p.products_id, p.products_type, p.master_categories_id, 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 
    and the same way in line 42:
    PHP Code:
    // We show them all
          
    $listing_sql "select " $select_column_list " p.products_id, p.products_type, p.master_categories_id, 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 
    Alternatively, you might need to add your field to the $select_column_list variable built in
    /includes/modules/pages/index/main_template_vars.php around line 157. This looks like it also requires some prep work, adding to $define_list above it:
    PHP Code:
      // create column list
      
    $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_IMAGE' => PRODUCT_LIST_IMAGE);

      
    /*                         ,
      'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW);
      */
      
    asort($define_list);
      
    reset($define_list);
      
    $column_list = array();
      foreach (
    $define_list as $key => $value)
      {
        if (
    $value 0$column_list[] = $key;
      }

      
    $select_column_list '';

      for (
    $i=0$n=sizeof($column_list); $i<$n$i++)
      {
        switch (
    $column_list[$i])
        {
          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_WEIGHT':
          
    $select_column_list .= 'p.products_weight, ';
          break;
        }
      } 
    Something like


    'PRODUCT_LIST_DELIVERY' => PRODUCT_LIST_DELIVERY

    where PRODUCT_LIST_DELIVERY is a constant defined by you in a similar way as the other constants in that list. This will require some research to find where those constants are defined and what they say. It probably also gets deeper into setting up a switch in admin to set the sort/display order of the new field, assuming you want to be able to control the behavior of the new field in the product listing.

    If you can just piggyback the new field onto another field so it always displays with it, you can probably avoid this work.
    Something like
    PHP Code:
          case 'PRODUCT_LIST_WEIGHT':
          
    $select_column_list .= 'p.products_weight, ';
          
    $select_column_list .= 'p.products_delivery, ';
          break; 
    if you want the weight and delivery to show together.

    I'm sure there is more involved in this whole process, but that's all I have time to look into right now.

  3. #13
    Join Date
    Aug 2005
    Location
    Southampton
    Posts
    80
    Plugin Contributions
    0

    Default Re: custom product field

    Thank you very much for your assistance. Your help is greatly appreciated.

  4. #14
    Join Date
    May 2008
    Posts
    442
    Plugin Contributions
    1

    red flag Re: custom product field

    I'm having this same issue, the below quote was a perfect explanation! However no solution was ever posted? Can someone from development please point me in the right direction to solve this issue? I added a new product field in the products table called: products_review_id

    I need to call the field contents from the product_listing.php page. I can get the product id field to populate using this code: '.$listing->fields['products_id'].' However is I change it to: '.$listing->fields['products_review_id'].' it is now working?
    Quote Originally Posted by chronicsys View Post
    hi,

    i have added a new product field to me products table by following this great post from crazy_chris: http://www.zen-cart.com/forum/showthread.php?t=57924

    everything works fine. i am able to edit values from admin and see results on product info page. http://www.zen-cart.com/forum/images/smilies/cool.gif

    i need to output this field on the product listing page - have been tryin in vain for a couple of days and have hit a brick wall it seems. must be missing something.

    in my custom product_listing.php template i can output any existing product fields with " $listing->fields['products_id']) "

    as soon as i try to reference my new field " $listing->fields['products_image_orientation']) " - it fails and outputs nothing. the same syntax works on product info page - no problem.

    can anyone point out what i am missing .... a thousand thank you's in advance .....

    [as you can see - i wish to store the orientation of my artwork / prints .... i tried initially to just calulate (width divided by height) but could not figure that out so opted to hard code it as a product attribute]

    http://www.zen-cart.com/forum/images/smilies/blink.gif

  5. #15
    Join Date
    May 2008
    Posts
    442
    Plugin Contributions
    1

    Default Re: custom product field

    Ok I figured it out :) If someone can just verify this is the correct solution, that would be nice!

    I added:

    Original:
    $select_column_list = '';

    Modified:
    $select_column_list = 'p.products_review_id,';

    to this file:
    \includes\modules\pages\index\main_template_vars.php

 

 
Page 2 of 2 FirstFirst 12

Similar Threads

  1. v151 Custom Field or using Product Model
    By jen2swt in forum Customization from the Admin
    Replies: 1
    Last Post: 14 Feb 2014, 03:24 PM
  2. How do I add a custom field to my Product Listing Page?
    By rbarbour in forum Templates, Stylesheets, Page Layout
    Replies: 11
    Last Post: 31 Aug 2010, 02:46 PM
  3. Adding a custom field to a product
    By icywindow in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 9 Nov 2009, 01:53 AM
  4. Adding custom field from specials table to product listing and product info
    By davale in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 19 Oct 2007, 06:19 AM

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