Forums / Templates, Stylesheets, Page Layout / Main page featured products sort

Main page featured products sort

Locked

Views: 6,664

Results 1 to 16 of 16
This thread is locked. New replies are disabled.
30 May 2006, 12:41 PM
#1
freq avatar

freq

New Zenner

Join Date:
Dec 2004
Posts:
72
Plugin Contributions:
0

Main page featured products sort

I am trying to determine how to change the main page featured products box to have the same sort order every time. Right now the featured products, and i suppose other product boxes are randomly ordered every time the page loads.

The question was asked here previously, and went unanswered as far as I could tell.
http://www.zen-cart.com/forum/showthread.php?t=12757

Thank you,
-bb

i gave 50 bucks to zencart, and all i got was a great site :))

31 May 2006, 5:53 PM
#2
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,844
Plugin Contributions:
17

Re: Main page featured products sort

Have you been to Configuration, Featured Listing in the Admin section?

Third line from the bottom gives eight different options.

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

6 Jun 2006, 7:03 PM
#3
freq avatar

freq

New Zenner

Join Date:
Dec 2004
Posts:
72
Plugin Contributions:
0

Re: Main page featured products sort

I played with those options, and it still sorts the 9 featured items on my home page randomly every time i reload.

i gave 50 bucks to zencart, and all i got was a great site :))

6 Jun 2006, 9:08 PM
#4
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,844
Plugin Contributions:
17

Re: Main page featured products sort

When you said "9" it turned on the light bulb.

If you are talking about the "New Products for June" on the main page, that's under "New Listing".

Sorry about the misread.

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

6 Jun 2006, 9:35 PM
#5
ajeh avatar

ajeh

Oba-san

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

Re: Main page featured products sort

The /includes/modules/featured_products.php uses a random sort method on the select to produce the 9 or however many featured items in the centerbox utilizing:

$featured_products = $db->ExecuteRandomMulti($featured_products_query, MAX_DISPLAY_SEARCH_RESULTS_FEATURED);

What you are wanting it to alter this so the randomizer is not used ...

However, in order to do that, you need to look at the two possible select statements that are setup for the variable $featured_products_query and determin what sort order you actually want used then adjust the code ...

You would be altering the code in an override by copying that file to:

/includes/modules/your_template_dir

Then you can adjust the code to meet your needs ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

6 Jun 2006, 9:37 PM
#6
ajeh avatar

ajeh

Oba-san

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

Re: Main page featured products sort

dbltoe ... just a note ... each of those centerboxes have that neat ability to set:

1 How many products to select out of all of the Products

2 How many to display out of those Products that were selected

3 Randomize that selection

Nifty, eh? :cool:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

6 Jun 2006, 11:58 PM
#7
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,844
Plugin Contributions:
17

Re: Main page featured products sort

I followed you here from OSC and I'd follow you anywhere:clap: :hug:

Now if you could tell me how to make product attributes auto-wrap on screen size change?:unsure:

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

7 Jun 2006, 12:42 AM
#8
ajeh avatar

ajeh

Oba-san

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

Re: Main page featured products sort

Unfortuntely ... one of my weaker subjects is design work ...

This can be done with the CSS and template overrides ... but I am not the best at teaching this ... :cry:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

16 Jun 2006, 3:53 AM
#9
matzofast avatar

matzofast

New Zenner

Join Date:
Nov 2004
Posts:
32
Plugin Contributions:
0

Re: Main page featured products sort

I have traced the function call back to the "query_factory.php" however this function is very abstract with a lot of passed variables. Could you give us a hint on how to overwrite this call so that it mearly returns the query by "sort" or "product number"?

26 Mar 2007, 9:06 PM
#10
aspagarino avatar

aspagarino

New Zenner

Join Date:
Mar 2007
Location:
San Diego
Posts:
6
Plugin Contributions:
0

Re: Main page featured products sort

Thanks Linda and dbdltoe

Thanks for the advice. I tried to modify feature_produts.php by adding the fields and the ORDER BY to the queries and I still get the same result...

feature_produts.php (original)

 
<?php
/**
* featured_products module - prepares content for display
*
* @package modules
* @copyright Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: featured_products.php 4629 2006-09-28 15:29:18Z ajeh $
*/
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_name
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_name
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_name'], 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_name'] . '</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 = '<h2 class="centerBoxHeading">' . TABLE_HEADING_FEATURED_PRODUCTS . ($category_title != '' ? ' - ' . $category_title : '') . '</h2>';
} else {
$title = '<h2 class="centerBoxHeading">' . TABLE_HEADING_FEATURED_PRODUCTS . '</h2>';
}
$zc_show_featured = true;
}
}
?>

feature_produts.php (modified)

 
<?php
/**
* featured_products module - prepares content for display
*
* @package modules
* @copyright Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: featured_products.php 4629 2006-09-28 15:29:18Z ajeh $
*/
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_name, p.products_sort_order
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'] . "' ORDER BY p.products_sort_order";
} else {
$featured_products_query = "select distinct p.products_id, p.products_image, pd.products_name, p.products_sort_order
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'] . "' ORDER BY p.products_sort_order";
}
$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_name'], 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_name'] . '</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 = '<h2 class="centerBoxHeading"><a name="products" id="products">' . TABLE_HEADING_FEATURED_PRODUCTS . ($category_title != '' ? ' - ' . $category_title : '') . '</a></h2>';
} else {
$title = '<div class="centerBoxHeading"><a name="products" id="products">' . TABLE_HEADING_FEATURED_PRODUCTS . '</a></div>';
}
$zc_show_featured = true;
}
}
?>

Can someone help me figure this out?:down:

26 Mar 2007, 11:02 PM
#11
aspagarino avatar

aspagarino

New Zenner

Join Date:
Mar 2007
Location:
San Diego
Posts:
6
Plugin Contributions:
0

Re: Main page featured products sort

Found the solution... :laugh:

http://www.zen-cart.com/forum/showthread.php?t=13062&highlight=ExecuteRandomMulti

Edits to featured_products.php:

  1. append "order by featured_sort_id" to the two select statements
  2. change ExecuteRandomMulti() to Execute()
  3. change MoveNextRandom() to MoveNext()

I was missing steps 2 and 3.

18 Apr 2007, 9:01 PM
#12
marke avatar

marke

New Zenner

Join Date:
May 2006
Posts:
16
Plugin Contributions:
0

Re: Main page featured products sort

Actually the products table contains a field called products_sort_order, and that can be edited using the admin panel, so using that field is probably easier than adding a new field to the products_description table.

2 Oct 2008, 10:25 PM
#13
hayden avatar

hayden

New Zenner

Join Date:
May 2008
Location:
South Australia
Posts:
86
Plugin Contributions:
1

Re: Main page featured products sort

"Actually the products table contains a field called products_sort_order, and that can be edited using the admin panel, so using that field is probably easier than adding a new field to the products_description table."

agreed

3 Oct 2008, 9:48 AM
#14
tasniem avatar

tasniem

New Zenner

Join Date:
Jul 2008
Posts:
2
Plugin Contributions:
0

Re: Main page featured products sort

I want to only show featured products on the Main Page. Is that possible and if so how do I do this?

19 Feb 2009, 5:05 AM
#15
ve39 avatar

ve39

New Zenner

Join Date:
Sep 2008
Posts:
31
Plugin Contributions:
0

Re: Main page featured products sort

hey guys, i did those steps and now products are not random.
how do i sort them by price ?
thank you

"
2. change ExecuteRandomMulti() to Execute()
3. change MoveNextRandom() to MoveNext()
"

9 Apr 2010, 8:31 AM
#16
dgent avatar

dgent

Totally Zenned

Join Date:
Nov 2009
Location:
UK
Posts:
1,117
Plugin Contributions:
0

Re: Main page featured products sort

Does anyone know how to do the same with the Featured sidebox though, as this code only affects products on the main page.

I have 8 products on my store, and simply want to use the featured products sidebox as a fixed menu.

Many thanks.