Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 23
  1. #11
    Join Date
    May 2006
    Posts
    321
    Plugin Contributions
    0

    Default Re: New Product Box Sort Order

    Okay, Linda, I'm back...your post confused me and I just got to come back to look at it. So, where did you add this? Right now, they seem to be sorting in reverse order, ascending, rather than descending.

  2. #12
    Join Date
    May 2006
    Posts
    321
    Plugin Contributions
    0

    Default Re: New Product Box Sort Order

    Got it! For anyone else trying to do this, here's the code:

    PHP Code:
    <?php
    /**
     * new_products.php module
     *
     * @package modules
     * @copyright Copyright 2003-2007 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: new_products.php 6424 2007-05-31 05:59:21Z ajeh $
     */
    if (!defined('IS_ADMIN_FLAG')) {
      die(
    'Illegal Access');
    }

    // initialize vars
    $categories_products_id_list '';
    $list_of_products '';
    $new_products_query '';

    $display_limit zen_get_new_date_range();

    if ( ((
    $manufacturers_id && $_GET['filter_id'] == 0) || $_GET['music_genre_id'] > || $_GET['record_company_id'] > 0) || (!isset($new_products_category_id) || $new_products_category_id == '0') ) {
      
    $new_products_query "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
                                    p.products_date_added, p.products_price, p.products_type, p.master_categories_id
                               from " 
    TABLE_PRODUCTS " p, " TABLE_PRODUCTS_DESCRIPTION " pd
                               where p.products_id = pd.products_id
                               and pd.language_id = '" 
    . (int)$_SESSION['languages_id'] . "'
                               and   p.products_status = 1 " 
    $display_limit;
    } else {
      
    // get all products and cPaths in this subcat tree
      
    $productsInCategory zen_get_categories_products_list( (($manufacturers_id && $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), falsetrue0$display_limit);

      if (
    is_array($productsInCategory) && sizeof($productsInCategory) > 0) {
        
    // build products-list string to insert into SQL query
        
    foreach($productsInCategory as $key => $value) {
          
    $list_of_products .= $key ', ';
        }
        
    $list_of_products substr($list_of_products0, -2); // remove trailing comma

        
    $new_products_query "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
                                      p.products_date_added, p.products_price, p.products_type, p.master_categories_id
                               from " 
    TABLE_PRODUCTS " p, " TABLE_PRODUCTS_DESCRIPTION " pd
                               where p.products_id = pd.products_id
                               and pd.language_id = '" 
    . (int)$_SESSION['languages_id'] . "'
                               and p.products_id in (" 
    $list_of_products ")";
      }
    }
    $new_products_query .= " ORDER BY products_date_added DESC
                            LIMIT " 
    MAX_DISPLAY_NEW_PRODUCTS;

    if (
    $new_products_query != ''$new_products $db->Execute($new_products_query);

    $row 0;
    $col 0;
    $list_box_contents = array();
    $title '';

    $num_products_count = ($new_products_query == '') ? $new_products->RecordCount();

    // show only when 1 or more
    if ($num_products_count 0) {
      if (
    $num_products_count SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS || SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS == ) {
        
    $col_width floor(100/$num_products_count);
      } else {
        
    $col_width floor(100/SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS);
      }

      while (!
    $new_products->EOF) {
        
    $products_price zen_get_products_display_price($new_products->fields['products_id']);
        if (!isset(
    $productsInCategory[$new_products->fields['products_id']])) $productsInCategory[$new_products->fields['products_id']] = zen_get_generated_category_path_rev($new_products->fields['master_categories_id']);

        
    $list_box_contents[$row][$col] = array('params' => 'class="centerBoxContentsNew centeredContent back"' ' ' 'style="width:' $col_width '%;"',
        
    'text' => (($new_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' '<a href="' zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' $productsInCategory[$new_products->fields['products_id']] . '&products_id=' $new_products->fields['products_id']) . '">' zen_image(DIR_WS_IMAGES $new_products->fields['products_image'], $new_products->fields['products_name'], IMAGE_PRODUCT_NEW_WIDTHIMAGE_PRODUCT_NEW_HEIGHT) . '</a><br />') . '<a href="' zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' $productsInCategory[$new_products->fields['products_id']] . '&products_id=' $new_products->fields['products_id']) . '">' $new_products->fields['products_name'] . '</a><br />' $products_price);

        
    $col ++;
        if (
    $col > (SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS 1)) {
          
    $col 0;
          
    $row ++;
        }
        
    $new_products->MoveNext();
      }

      if (
    $new_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">' sprintf(TABLE_HEADING_NEW_PRODUCTSstrftime('%B')) . ($category_title != '' ' - ' $category_title '' ) . '</h2>';
        } else {
          
    $title '<h2 class="centerBoxHeading">' sprintf(TABLE_HEADING_NEW_PRODUCTSstrftime('%B')) . '</h2>';
        }
        
    $zc_show_new_products true;
      }
    }
    ?>
    That's the entire modules/new_products.php file. If you are using a custom template, be sure to put it in your custom template folder inside the modules folder.

    Thanks!

  3. #13
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: New Product Box Sort Order

    Glad that you have this working now ... thanks for the update ...
    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!

  4. #14
    Join Date
    May 2006
    Posts
    321
    Plugin Contributions
    0

    Default Re: New Product Box Sort Order

    Okay, we have a problem...

    We have a category with subcategories and there are no new products to display in it or specials to display in it, we are getting this:

    On one category in this client's shop, we are getting this:

    1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY products_date_added DESC LIMIT 1' at line 1
    in:
    [ ORDER BY products_date_added DESC LIMIT 1]

    The other top level category has both specials and new products and it is working fine. When I take out the file that I did for this, the error goes away so it has to be this...can you please help me figure out what's wrong with the code?

  5. #15
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: New Product Box Sort Order

    I think you will need to move the additional code:
    Code:
    $new_products_query .= " ORDER BY products_date_added DESC
                            LIMIT " . MAX_DISPLAY_NEW_PRODUCTS;
    Directly below the two original statements for the:
    $new_products_query

    so that it will be blank if neither can happen ...

    More or less what is happening now is that the statement reads under some conditions:
    " ORDER BY products_date_added DESC
    LIMIT " . MAX_DISPLAY_NEW_PRODUCTS;
    So that does not mean anything when it goes to processes the SELECT statement, thus, it throws that error from time to time ...
    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. #16
    Join Date
    May 2006
    Posts
    321
    Plugin Contributions
    0

    Default Re: New Product Box Sort Order

    Okay, so this would be the code, then?

    PHP Code:
    <?php
    /**
     * new_products.php module
     *
     * @package modules
     * @copyright Copyright 2003-2007 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: new_products.php 6424 2007-05-31 05:59:21Z ajeh $
     */
    if (!defined('IS_ADMIN_FLAG')) {
      die(
    'Illegal Access');
    }

    // initialize vars
    $categories_products_id_list '';
    $list_of_products '';
    $new_products_query '';

    $display_limit zen_get_new_date_range();

    if ( ((
    $manufacturers_id && $_GET['filter_id'] == 0) || $_GET['music_genre_id'] > || $_GET['record_company_id'] > 0) || (!isset($new_products_category_id) || $new_products_category_id == '0') ) {
      
    $new_products_query "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
                                    p.products_date_added, p.products_price, p.products_type, p.master_categories_id
                               from " 
    TABLE_PRODUCTS " p, " TABLE_PRODUCTS_DESCRIPTION " pd
                               where p.products_id = pd.products_id
                               and pd.language_id = '" 
    . (int)$_SESSION['languages_id'] . "'
                               and   p.products_status = 1 " 
    $display_limit;
                                
    $new_products_query .= " ORDER BY products_date_added DESC
                            LIMIT " 
    MAX_DISPLAY_NEW_PRODUCTS;
    } else {
      
    // get all products and cPaths in this subcat tree
      
    $productsInCategory zen_get_categories_products_list( (($manufacturers_id && $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), falsetrue0$display_limit);

      if (
    is_array($productsInCategory) && sizeof($productsInCategory) > 0) {
        
    // build products-list string to insert into SQL query
        
    foreach($productsInCategory as $key => $value) {
          
    $list_of_products .= $key ', ';
        }
        
    $list_of_products substr($list_of_products0, -2); // remove trailing comma

        
    $new_products_query "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
                                      p.products_date_added, p.products_price, p.products_type, p.master_categories_id
                               from " 
    TABLE_PRODUCTS " p, " TABLE_PRODUCTS_DESCRIPTION " pd
                               where p.products_id = pd.products_id
                               and pd.language_id = '" 
    . (int)$_SESSION['languages_id'] . "'
                               and p.products_id in (" 
    $list_of_products ")";
                               
                               
    $new_products_query .= " ORDER BY products_date_added DESC
                            LIMIT " 
    MAX_DISPLAY_NEW_PRODUCTS;
      }
    }


    if (
    $new_products_query != ''$new_products $db->Execute($new_products_query);

    $row 0;
    $col 0;
    $list_box_contents = array();
    $title '';

    $num_products_count = ($new_products_query == '') ? $new_products->RecordCount();

    // show only when 1 or more
    if ($num_products_count 0) {
      if (
    $num_products_count SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS || SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS == ) {
        
    $col_width floor(100/$num_products_count);
      } else {
        
    $col_width floor(100/SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS);
      }

      while (!
    $new_products->EOF) {
        
    $products_price zen_get_products_display_price($new_products->fields['products_id']);
        if (!isset(
    $productsInCategory[$new_products->fields['products_id']])) $productsInCategory[$new_products->fields['products_id']] = zen_get_generated_category_path_rev($new_products->fields['master_categories_id']);

        
    $list_box_contents[$row][$col] = array('params' => 'class="centerBoxContentsNew centeredContent back"' ' ' 'style="width:' $col_width '%;"',
        
    'text' => (($new_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' '<a href="' zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' $productsInCategory[$new_products->fields['products_id']] . '&products_id=' $new_products->fields['products_id']) . '">' zen_image(DIR_WS_IMAGES $new_products->fields['products_image'], $new_products->fields['products_name'], IMAGE_PRODUCT_NEW_WIDTHIMAGE_PRODUCT_NEW_HEIGHT) . '</a><br />') . '<a href="' zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' $productsInCategory[$new_products->fields['products_id']] . '&products_id=' $new_products->fields['products_id']) . '">' $new_products->fields['products_name'] . '</a><br />' $products_price);

        
    $col ++;
        if (
    $col > (SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS 1)) {
          
    $col 0;
          
    $row ++;
        }
        
    $new_products->MoveNext();
      }

      if (
    $new_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">' sprintf(TABLE_HEADING_NEW_PRODUCTSstrftime('%B')) . ($category_title != '' ' - ' $category_title '' ) . '</h2>';
        } else {
          
    $title '<h2 class="centerBoxHeading">' sprintf(TABLE_HEADING_NEW_PRODUCTSstrftime('%B')) . '</h2>';
        }
        
    $zc_show_new_products true;
      }
    }
    ?>
    It seems to have corrected the problem and all looks okay. Thought I'd come back and repost it so someone else didn't have the same problem. If you'd like to edit my previous post with the code, it might save someone the same error :) .

    Thanks!!

  7. #17
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: New Product Box Sort Order

    Glad that this worked for you ...

    I missed the part that the original IF processes a blank under some conditions then later tests that the variable is blank or not ... but doesn't know that it is not complete ... silly silly me ...
    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!

  8. #18
    Join Date
    Jun 2009
    Location
    Miami, Fl
    Posts
    138
    Plugin Contributions
    0

    Default Re: New Product Box Sort Order

    I followed your code (I mean I replaced for mine) but the result is the same. When user click "New Products" it show some products but the default sort is "TEXT_INFO_SORT_BY_SORT_ORDER"

    Can anybody help me to replace that default for the "Date Added - New to old" ?

    Thanks.

  9. #19
    Join Date
    May 2007
    Posts
    29
    Plugin Contributions
    0

    Default Re: New Product Box Sort Order

    Hi, this solution no longer seems to work for 1.3.9b; whenever I use this version of new_products.php the box just disappears altogether. Any chance someone could update this file to be compatible with the new version? it's really driving me crazy that I can't sort this box in descending order.

  10. #20
    Join Date
    May 2007
    Posts
    29
    Plugin Contributions
    0

    Default Re: New Product Box Sort Order

    OK, I still can't figure this out... can anyone help? I'm trying to update the select statement to order by date added, but there must be an error somewhere because when I use this query the box disappears altogether (no error message, though):

    PHP Code:
        $new_products_query "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
                                      p.products_date_added, p.products_price, p.products_type, p.master_categories_id
                               from " 
    TABLE_PRODUCTS " p, " TABLE_PRODUCTS_DESCRIPTION " pd
                               where p.products_id = pd.products_id
                               and pd.language_id = '" 
    . (int)$_SESSION['languages_id'] . "'
                               and p.products_status = 1
                               and p.products_id in (" 
    $list_of_products ")";

    ######################################################$new_products_query##.=##"##ORDER##BY##products_date_added##DESC "; 
    Any ideas? Thanks!


    Oh, and in case it's useful here's the entirety of the new_products.php:

    PHP Code:
    <?php
    /**
     * new_products.php module
     *
     * @package modules
     * @copyright Copyright 2003-2008 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: new_products.php 8730 2008-06-28 01:31:22Z drbyte $
     */
    if (!defined('IS_ADMIN_FLAG')) {
      die(
    'Illegal Access');
    }

    // initialize vars
    $categories_products_id_list '';
    $list_of_products '';
    $new_products_query '';

    $display_limit zen_get_new_date_range();

    if ( ((
    $manufacturers_id && $_GET['filter_id'] == 0) || $_GET['music_genre_id'] > || $_GET['record_company_id'] > 0) || (!isset($new_products_category_id) || $new_products_category_id == '0') ) {
      
    $new_products_query "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
                                    p.products_date_added, p.products_price, p.products_type, p.master_categories_id
                               from " 
    TABLE_PRODUCTS " p, " TABLE_PRODUCTS_DESCRIPTION " pd
                               where p.products_id = pd.products_id
                               and pd.language_id = '" 
    . (int)$_SESSION['languages_id'] . "'
                               and   p.products_status = 1 " 
    $display_limit;
    } else {
      
    // get all products and cPaths in this subcat tree
      
    $productsInCategory zen_get_categories_products_list( (($manufacturers_id && $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), falsetrue0$display_limit);

      if (
    is_array($productsInCategory) && sizeof($productsInCategory) > 0) {
        
    // build products-list string to insert into SQL query
        
    foreach($productsInCategory as $key => $value) {
          
    $list_of_products .= $key ', ';
        }
        
    $list_of_products substr($list_of_products0, -2); // remove trailing comma

        
    $new_products_query "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
                                      p.products_date_added, p.products_price, p.products_type, p.master_categories_id
                               from " 
    TABLE_PRODUCTS " p, " TABLE_PRODUCTS_DESCRIPTION " pd
                               where p.products_id = pd.products_id
                               and pd.language_id = '" 
    . (int)$_SESSION['languages_id'] . "'
                               and p.products_status = 1
                               and p.products_id in (" 
    $list_of_products ")";

    ######################################################$new_products_query##.=##"##ORDER##BY##products_date_added##DESC "; 
      
    }
    }

    if (
    $new_products_query != ''$new_products $db->Execute($new_products_queryMAX_DISPLAY_NEW_PRODUCTS);

    $row 0;
    $col 0;
    $list_box_contents = array();
    $title '';

    $num_products_count = ($new_products_query == '') ? $new_products->RecordCount();

    // show only when 1 or more
    if ($num_products_count 0) {
      if (
    $num_products_count SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS || SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS == ) {
        
    $col_width floor(100/$num_products_count);
      } else {
        
    $col_width floor(100/SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS);
      }

      while (!
    $new_products->EOF) {
        
    $products_price zen_get_products_display_price($new_products->fields['products_id']);
        if (!isset(
    $productsInCategory[$new_products->fields['products_id']])) $productsInCategory[$new_products->fields['products_id']] = zen_get_generated_category_path_rev($new_products->fields['master_categories_id']);

        
    $list_box_contents[$row][$col] = array('params' => 'class="centerBoxContentsNew centeredContent back"' ' ' 'style="width:' $col_width '%;"',
        
    'text' => (($new_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' '<a href="' zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' $productsInCategory[$new_products->fields['products_id']] . '&products_id=' $new_products->fields['products_id']) . '">' zen_image(DIR_WS_IMAGES $new_products->fields['products_image'], $new_products->fields['products_name'], IMAGE_PRODUCT_NEW_WIDTHIMAGE_PRODUCT_NEW_HEIGHT) . '</a><br />') . '<a href="' zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' $productsInCategory[$new_products->fields['products_id']] . '&products_id=' $new_products->fields['products_id']) . '">' $new_products->fields['products_name'] . '</a><br />' $products_price);

        
    $col ++;
        if (
    $col > (SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS 1)) {
          
    $col 0;
          
    $row ++;
        }
        
    $new_products->MoveNext();
      }

      if (
    $new_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">' sprintf(TABLE_HEADING_NEW_PRODUCTSstrftime('%B')) . ($category_title != '' ' - ' $category_title '' ) . '</h2>';
        } else {
          
    $title '<h2 class="centerBoxHeading">' sprintf(TABLE_HEADING_NEW_PRODUCTSstrftime('%B')) . '</h2>';
        }
        
    $zc_show_new_products true;
      }
    }
    ?>

 

 
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. v139h Product sort order on New Products Page not working
    By jmsnyder23 in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 4 Aug 2014, 02:34 PM
  2. v151 Product Sort within Category - having problems changing the default sort order
    By Don Wagner in forum Customization from the Admin
    Replies: 4
    Last Post: 21 Oct 2012, 03:03 AM
  3. Change sort order in new products box on index.php page
    By jolewin in forum Customization from the Admin
    Replies: 2
    Last Post: 28 Mar 2011, 05:11 AM
  4. New Products Center Box Sort Order
    By jordandsa in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 24 Sep 2009, 07:19 PM
  5. Specials Box - sort order
    By skype55 in forum Setting Up Specials and SaleMaker
    Replies: 1
    Last Post: 24 Feb 2008, 03:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg