Zen Cart Logo
Forums / General Questions / Additional Columns in Product Listing

Additional Columns in Product Listing

Locked

Views: 1,126

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
24 Jul 2006, 12:49 AM
#1
webavant avatar

webavant

New Zenner

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

Additional Columns in Product Listing

I would like to do one of the following two things:

  1. Add additional columns/fields to products and display them sortable in the product listing.

  2. Display the attribute sortable in the product listing

Is there a module or a how-to that can accomplish this? If not, does anyone know of a cart that can handle it out-of-the-box for free or at cost?

24 Jul 2006, 8:39 AM
#2
webavant avatar

webavant

New Zenner

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

Re: Additional Columns in Product Listing

Check this post: There is an OS Commerce mod that does exactly this: http://www.zen-cart.com/forum/showthread.php?t=32004.

Does anyone have a decent guide as to how this could be ported to ZCart? The Wiki site is down!!! o.O

24 Jul 2006, 10:19 AM
#3
webavant avatar

webavant

New Zenner

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

Re: Additional Columns in Product Listing

Hmm... it seems there is no solution available on this website in this regard. Most of the code that the OSC mod handles is obsolete and moved around to other files, making it pretty useless for ZC.

I'm having a bit of luck modding ZC myself, except I was having difficulty creating a new table and joining it to the product listing tables... I've currently just added a few fields to the product table to avoid modifying the SQL. Any good example of how to add an SQL join statement to the default_filter.php? I'm kind of a newbie.

26 Jul 2006, 8:01 PM
#4
l5eoneill avatar

l5eoneill

New Zenner

Join Date:
Jul 2006
Location:
Beautiful Maine
Posts:
7
Plugin Contributions:
0

Re: Additional Columns in Product Listing

The music genre filter shows sql joins for product_extra tables. It should be in the same folder as your default_filter.php file. If not, here's a sample (it has several other tables joined in, which you can delete if you only need one joined table):

$listing_sql = "select " . $select_column_list . " p.products_id, p.products_type, 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
        from " . TABLE_PRODUCTS . " p, " .
        TABLE_PRODUCTS_DESCRIPTION . " pd, " .
        TABLE_PRODUCT_MUSIC_EXTRA . " pme left join " . TABLE_SPECIALS . " s on pme.products_id = s.products_id, " .
        TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " .
        TABLE_MUSIC_GENRE . " m
        where  m.music_genre_id = '" . (int)$_GET['music_genre_id'] . "'
          and p.products_id = pme.products_id
          and p.products_status = 1
          and pme.music_genre_id = '" . (int)$_GET['music_genre_id'] . "'
          and pme.products_id = p2c.products_id
          and pd.products_id = p2c.products_id
          and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
          and p2c.categories_id = '" . (int)$_GET['filter_id'] . "'";

If deleting some joins, be careful with your string closures and concatenations.

Here it is with just the one extra table joined:

$listing_sql = "select " . $select_column_list . " p.products_id, p.products_type, 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, pme.[your extra field here]
        from " . TABLE_PRODUCTS . " p, " .
        TABLE_PRODUCTS_DESCRIPTION . " pd, " .
        TABLE_PRODUCT_MUSIC_EXTRA . " pme left join " . TABLE_SPECIALS . " s on pme.products_id = s.products_id, " .
        TABLE_PRODUCTS_TO_CATEGORIES . " p2c
	where  p.products_id = pme.products_id
          and p.products_status = 1
          and pme.products_id = p2c.products_id
          and pd.products_id = p2c.products_id
          and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
          and p2c.categories_id = '" . (int)$_GET['filter_id'] . "'";

(untested)

But I think there's a lot more to it than just getting the table joined and adding a field or 3 to the query. Such as getting the info into the product listing display, sorting, etc.