Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1
    Join Date
    Dec 2004
    Posts
    76
    Plugin Contributions
    0

    Default 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 :))

  2. #2
    Join Date
    Jan 2004
    Location
    N of San Antonio TX
    Posts
    5,006
    Plugin Contributions
    6

    Default 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.
    Did you read the posting tips?!?
    Things We've Done
    MOD: Scheduled Events

  3. #3
    Join Date
    Dec 2004
    Posts
    76
    Plugin Contributions
    0

    Default 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 :))

  4. #4
    Join Date
    Jan 2004
    Location
    N of San Antonio TX
    Posts
    5,006
    Plugin Contributions
    6

    Default 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.
    Did you read the posting tips?!?
    Things We've Done
    MOD: Scheduled Events

  5. #5
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    64,726
    Plugin Contributions
    6

    Default 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:

    PHP Code:
    $featured_products $db->ExecuteRandomMulti($featured_products_queryMAX_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: v1.5.1]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...

  6. #6
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    64,726
    Plugin Contributions
    6

    Default 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?
    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: v1.5.1]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...

  7. #7
    Join Date
    Jan 2004
    Location
    N of San Antonio TX
    Posts
    5,006
    Plugin Contributions
    6

    Default Re: Main page featured products sort

    I followed you here from OSC and I'd follow you anywhere

    Now if you could tell me how to make product attributes auto-wrap on screen size change?
    Did you read the posting tips?!?
    Things We've Done
    MOD: Scheduled Events

  8. #8
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    64,726
    Plugin Contributions
    6

    Default 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 ...
    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: v1.5.1]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...

  9. #9
    Join Date
    Nov 2004
    Posts
    37
    Plugin Contributions
    0

    Default 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"?

  10. #10
    Join Date
    Mar 2007
    Location
    San Diego
    Posts
    6
    Plugin Contributions
    0

    Default 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 Code:
    <?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_queryMAX_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_WIDTHIMAGE_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 Code:
    <?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_queryMAX_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_WIDTHIMAGE_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?

 

 
Page 1 of 2 12 LastLast

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
  •