Forums / Setting Up Categories, Products, Attributes / New Product Box Sort Order

New Product Box Sort Order

Started by ebaobao on 4 Sep 2008, 8:38 PM · Views: 8,816

Results 21 to 23 of 23
17 May 2010, 4:35 PM
#21
ajeh avatar

ajeh

Oba-san

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

New Product Box Sort Order

The line with all the ######### is causing the error ... comments are done with two forward slashes // in php not the # sign ...

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!

18 Nov 2010, 4:23 AM
#22
kaniki avatar

kaniki

Zen Follower

Join Date:
Sep 2010
Posts:
111
Plugin Contributions:
0

Re: New Product Box Sort Order

You- Are A LIFESAVER digidiva kathy!!! This solved all my problems with the random sort order- GOD BLESS YOU!!! Oh my goodness!! Been at this ALL DAY--- and it was here- in your post..

Great work!! Thank you - thank you- and oh thank you!!!!

6 Apr 2011, 8:03 AM
#23
miri avatar

miri

New Zenner

Join Date:
Mar 2011
Posts:
6
Plugin Contributions:
0

Re: New Product Box Sort Order

digidiva-kathy:

Okay, so this would be the code, then?

<?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 > 0 && $_GET['filter_id'] == 0) || $_GET['music_genre_id'] > 0 || $_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 > 0 && $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0, $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_products, 0, -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 == '') ? 0 : $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 == 0 ) { $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_WIDTH, IMAGE_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_PRODUCTS, strftime('%B')) . ($category_title != '' ? ' - ' . $category_title : '' ) . '</h2>'; } else { $title = '<h2 class="centerBoxHeading">' . sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%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!!

I tried to use this solution and it worked on the top page!!
I show new products on each categories too and it seems like they show products which status is out of stock.
(original new_products.php file doesn't show them)
Does anyone can fix this??

Thank you so much!!

Rie