Zen Cart Logo
Forums / Basic Configuration / Change Featured Products Display

Change Featured Products Display

Locked

Views: 2,188

Results 1 to 11 of 11
This thread is locked. New replies are disabled.
28 May 2007, 9:01 PM
#1
margecc avatar

margecc

Zen Follower

Join Date:
Feb 2007
Location:
Ontario, Canada
Posts:
234
Plugin Contributions:
0

Change Featured Products Display

In the featured products on my main page, I would like the model number to display rather than the title.

http://www.actionforms.ca/officesupplies/

IE, the first one shows "For Deskjet 450CI/CBI, 5150, 5550, 5650/W, 5850/W, 9650, 9670…" as the title, but I just want it to show "Model: HEWC6657AC" instead.

28 May 2007, 11:16 PM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Change Featured Products Display

Roll up your sleeves....tpl_modules_whats_new.php is the file but mostly only calls /includes/modules/new_products.php and in that file it gets the info for displaying with things like:

 $new_products_query = "select p.products_id,...and
$new_products->fields['products_name'] = zen_get_products_name($new_products->fields['products_id']);

Where you want the model...p.products_model or products_model depending.

I think at first glance that I would copy/clone this with a new name if you only want this for the main page as this is also used for the featured listing - yeah a bit more work but might be what you need

30 May 2007, 2:13 PM
#3
margecc avatar

margecc

Zen Follower

Join Date:
Feb 2007
Location:
Ontario, Canada
Posts:
234
Plugin Contributions:
0

Re: Change Featured Products Display

I want the featured products on all pages to be displayed with the model number instead of the title, so I think I can just customize instead of cloning which will hopefully make it easier.

I have opened the "new_products.php", however I know just enough php to make me dangerous but not useful. Should I not use the "featured_products.php" file?
I have rolled up my sleves and I am ready to type, if only I had a clue what I was doing!

31 May 2007, 7:22 PM
#4
margecc avatar

margecc

Zen Follower

Join Date:
Feb 2007
Location:
Ontario, Canada
Posts:
234
Plugin Contributions:
0

Re: Change Featured Products Display

Anybody? Help......

1 Jun 2007, 5:42 AM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Change Featured Products Display

To change the Featured Products Centerbox ...

You would want to customize the:
/includes/modules/featured_products.php

and copy to your templates and overrides directory:
/includes/modules/your_template_dir/featured_products.php

add the additional field(s) needed to the select statements ... then customize the display of the data ...

1 Jun 2007, 3:48 PM
#6
margecc avatar

margecc

Zen Follower

Join Date:
Feb 2007
Location:
Ontario, Canada
Posts:
234
Plugin Contributions:
0

Re: Change Featured Products Display

Maybe I'm not bright, but I have no idea how to switch it from name to model so I would love a little more guidance.

Both replys, I think, assume I have know a little more php than I do. I understand it to read it (somewhat), but writing my own stuff I leave to the smart ones!!

1 Jun 2007, 3:51 PM
#7
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Change Featured Products Display

The products_module is in the products table ... this is designated in the SELECT statements with p ...

If you added p.products_model then you now have the information available to you ...

If you look at how the products_name appears in the code to display it, you can now change that to the products_model ...

1 Jun 2007, 4:08 PM
#8
margecc avatar

margecc

Zen Follower

Join Date:
Feb 2007
Location:
Ontario, Canada
Posts:
234
Plugin Contributions:
0

Re: Change Featured Products Display

Ok, this is what I did and I lost my featured products and my entire right column:

 
if (!defined('IS_ADMIN_FLAG')) {
die('Illegal Access');
}
if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
$featured_products_query = "select distinct p.products_id, p.products_image, pd.products_model
from (" . TABLE_PRODUCTS . " p
left join " . TABLE_FEATURED . " f on p.products_id = f.products_id
left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id )
where p.products_id = f.products_id and p.products_id = pd.products_id and p.products_status = 1 and f.status = 1 and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";
} else {
$featured_products_query = "select distinct p.products_id, p.products_image, pd.products_model
from (" . TABLE_PRODUCTS . " p
left join " . TABLE_FEATURED . " f on p.products_id = f.products_id
left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id), " .
TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " .
TABLE_CATEGORIES . " c
where p.products_id = p2c.products_id
and p2c.categories_id = c.categories_id
and c.parent_id = '" . (int)$new_products_category_id . "'
and p.products_id = f.products_id and p.products_id = pd.products_id and p.products_status = 1 and f.status = 1 and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";
}
$featured_products = $db->ExecuteRandomMulti($featured_products_query, MAX_DISPLAY_SEARCH_RESULTS_FEATURED);
$row = 0;
$col = 0;
$list_box_contents = array();
$title = '';
$num_products_count = $featured_products->RecordCount();
// show only when 1 or more
if ($num_products_count > 0) {
if ($num_products_count < SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS || SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS == 0) {
$col_width = floor(100/$num_products_count);
} else {
$col_width = floor(100/SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS);
}
while (!$featured_products->EOF) {
$products_price = zen_get_products_display_price($featured_products->fields['products_id']);
$list_box_contents[$row][$col] = array('params' =>'class="centerBoxContentsFeatured centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
'text' => (($featured_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $featured_products->fields['products_image'], $featured_products->fields['products_model'], IMAGE_FEATURED_PRODUCTS_LISTING_WIDTH, IMAGE_FEATURED_PRODUCTS_LISTING_HEIGHT) . '</a><br />') . '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']) . '">' . $featured_products->fields['products_model'] . '</a><br />' . $products_price);
$col ++;
if ($col > (SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS - 1)) {
$col = 0;
$row ++;
}
$featured_products->MoveNextRandom();
}
if ($featured_products->RecordCount() > 0) {
if (isset($new_products_category_id) && $new_products_category_id !=0) {
$category_title = zen_get_categories_name((int)$new_products_category_id);
$title = zen_image($template->get_template_dir(TABLE_HEADING_FEATURED_PRODUCTS, DIR_WS_TEMPLATE, $current_page_base,'images'). '/' . TABLE_HEADING_FEATURED_PRODUCTS, HEADER_ALT_TEXT);
} else {
$title = zen_image($template->get_template_dir(TABLE_HEADING_FEATURED_PRODUCTS, DIR_WS_TEMPLATE, $current_page_base,'images'). '/' . TABLE_HEADING_FEATURED_PRODUCTS, HEADER_ALT_TEXT);
}
$zc_show_featured = true;
}
}
?>

I did a search for p.products_name and changed it to p.products_model and all instances of products_name to products_model.

1 Jun 2007, 4:14 PM
#9
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Change Featured Products Display

You appear to have lost all formating so assuming the file is trashed out ...

Start with a clean copy of the:
/includes/modules/featured_products.php

and copy to your templates and overrides directory:
/includes/modules/your_template_dir/featured_products.php

Next, find in the two SELECT statements where it references:

pd.products_name

and add:

, p.products_model

Next, look for the code:

$featured_products->fields['products_name']

to show the products_model instead, change to read:

$featured_products->fields['products_model']

What you did is call from pd.products_model ... pd is the products_description tabel ... p is the products table where the products_model is located ... :smile:

1 Jun 2007, 4:21 PM
#10
margecc avatar

margecc

Zen Follower

Join Date:
Feb 2007
Location:
Ontario, Canada
Posts:
234
Plugin Contributions:
0

Re: Change Featured Products Display

YOUR ROCK! Your brillance sends me into fits of envy!!

Thanks! That worked perfect. I didn't understand the pd. vs p. thing!!

1 Jun 2007, 5:18 PM
#11
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Change Featured Products Display

Glad that this worked for you ... :smile:

When reading a SELECT statement ... always watch for the letter(s) following it as that is how the tables are distinguished from each other ...

We try to make them make sense with p for products and pd for products_description etc. You just have to then look to see which table a field is in to add it to an existing SELECT statement ... :cool: