Zen Cart Logo
Forums / Setting Up Categories, Products, Attributes / displaying attributes in product listing

displaying attributes in product listing

Locked

Views: 1,824

Results 1 to 7 of 7
This thread is locked. New replies are disabled.
24 Jun 2008, 7:58 PM
#1
thebigkrumm avatar

thebigkrumm

New Zenner

Join Date:
Jun 2008
Posts:
13
Plugin Contributions:
0

displaying attributes in product listing

I can't figure out which file to edit to add an attribute on my product listing page :(

I'm starting a music store, and the way I have my inventory set up is that the Product's Name is the artist (eg, Neil Diamond) and the particular album is an attribute I set up elsewhere. This attribute already displays on the particular item info (as it should) but I would also like to to show up in lieu of the product description on the Product Listing page (the general category, in this case, 1970s.) I'm pretty sure I can figure out how to make that happen if someone can just tell me which PHP file to edit for that page -- I can't find it :(

Thanks!

26 Jun 2008, 3:38 PM
#2
thebigkrumm avatar

thebigkrumm

New Zenner

Join Date:
Jun 2008
Posts:
13
Plugin Contributions:
0

Re: displaying attributes in product listing

OK, I found the file in ../includes/modules/product_listing.php; the code is throwing me. Where can I add the code to display the attribute? In a perfect world, I'd like to delete the product description and add the attribute, a simple tit-for-tat; is there an easy way?

26 Jun 2008, 3:50 PM
#3
gjh42 avatar

gjh42

Black Belt

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

Re: displaying attributes in product listing

No, there is not an easy way (unless you are a PHP/MySQL professional).
The listings are not set up to process attributes. It can be done, but involves a lot of custom coding.

Is your idea to have multiple albums show up as attributes under each "artist's name" product?

27 Jun 2008, 6:26 PM
#4
thebigkrumm avatar

thebigkrumm

New Zenner

Join Date:
Jun 2008
Posts:
13
Plugin Contributions:
0

Re: displaying attributes in product listing

no, I think that may be too difficult -- instead, each record has its own product ID. Tom Petty, for instance, is the Product Name and Album is an attribute. Tom Petty - Damn the Torpedoes and Tom Petty - Into the Great Wide Open are different products. The attributes are already stored in the main SQL database, and I have the attributes displaying when you click on a specific product -- I'd like to have that attribute also appear on the product listing page within the specific category (in this case, 1970's.) I don't need the product description to display.

I'm surprised there isn't just a quick call to the product description data within the database that I could just edit to return a different field -- but then, I'm not the world's greatest coder, either :)

28 Jun 2008, 6:20 AM
#5
gjh42 avatar

gjh42

Black Belt

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

Re: displaying attributes in product listing

What you describe doesn't sound like a good use of attributes. Why do you feel it is necessary to use attributes at all in this case?
Since you apparently only want read-only attributes (there is nothing to select), you could run a db query to display that.

I would think making the product names Tom Petty - Damn the Torpedoes and Tom Petty - Into the Great Wide Open, or else a subcategory called Tom Petty with products named Damn the Torpedoes and Into the Great Wide Open would work better.

29 Jun 2008, 2:36 PM
#6
thebigkrumm avatar

thebigkrumm

New Zenner

Join Date:
Jun 2008
Posts:
13
Plugin Contributions:
0

Re: displaying attributes in product listing

gjh42:

What you describe doesn't sound like a good use of attributes. Why do you feel it is necessary to use attributes at all in this case?
Since you apparently only want read-only attributes (there is nothing to select), you could run a db query to display that.

I would think making the product names Tom Petty - Damn the Torpedoes and Tom Petty - Into the Great Wide Open, or else a subcategory called Tom Petty with products named Damn the Torpedoes and Into the Great Wide Open would work better.

The reason for the read-only attributes is so that data entry is much faster; I deal in used merchandise, so I have to describe it to the customer. Other attributes I have include Vinyl Condition, Cover Condition, and the album year; by making them fields in the data collection screen, I can save a lot of time instead of manually typing those characteristics in the product description. The problem with sub-categories is that I'll have hundreds of them, and if, for instance, I run out of Tom Petty albums I'll just have an empty sub-category; in the scenario I'm running now, they just won't appear if I don't have any in stock.

As far as the database query is concerned, I looked in my PRODUCT_LISTING.PHP file and I couldn't find the query for the description -- I think the zen-cart field is product_description or something like that; like I said, I'm not the best coder in the world, but I think I'm in the right place - I just need a little boost to get me where I need to go. How does the product listing screen read the product description to return it? Is that a simple database query that I can just edit to be my products_album_name field?

29 Jun 2008, 6:59 PM
#7
gjh42 avatar

gjh42

Black Belt

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

Re: displaying attributes in product listing

Using read-only attributes for condition and such sounds reasonable. I still think it makes more sense for the product name to include the album title, like Tom Petty - Damn the Torpedoes. That's not just an attribute, it IS the product, and deserves equal weight in the listing display with the artist name. I do understand not making the artists into subcats as you state.

The db lookup is more complicated, and I'm not sure exactly where the code to modify would be.
At the top of product_listing.php is this line:

$listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_PRODUCTS_LISTING, 'p.products_id', 'page');

and farther down is this:

$listing = $db->Execute($listing_split->sql_query);

so $listing_split is an instance of the splitPageResults class, and you might find splitPageResults() in /includes/classes/??. Use the Developers Toolkit in admin > Tools to find the file.