Forums / Setting Up Categories, Products, Attributes / Product sort order doesn't work- products display randomly!

Product sort order doesn't work- products display randomly!

Locked

Views: 2,577

Results 1 to 10 of 10
This thread is locked. New replies are disabled.
2 Dec 2007, 9:46 PM
#1
ajshim avatar

ajshim

New Zenner

Join Date:
Dec 2007
Posts:
5
Plugin Contributions:
0

Product sort order doesn't work- products display randomly!

The products on both my store Homepage and Category pages are being displayed in a random sort order. I've tried changing the following values to no avail:

-Congifuration > Layout Settings > Categories/Products Display Sort Order
-Configuration> All Listing > Display Product Display - Default Sort Order

I'm using a custom template and perhaps some where along the way, a piece of code was incorrectly manipulated. In my template file, under templates/tpl_modules_product_listing.php I see the following code:

$new_products = $db->ExecuteRandomMulti($listing_sql, MAX_DISPLAY_NEW_PRODUCTS);

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

$num_products_count = $new_products->RecordCount();

define('SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS', 4);
// 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']);

$new_products->fields['products_name'] = zen_get_products_name($new_products->fields['products_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) ? '' : '<div class="product_image"><a href="' . zen_href_link(zen_get_info_page($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></div>') . '<div class="product_info"><span class="product_name"><a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'products_id=' . $new_products->fields['products_id']) . '">' . $new_products->fields['products_name'] . '</a></span><span class="product_price">' . $products_price . "</span></div>");

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

}

/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;
}
/
}
?>

<div id="productListing"> <?php // only show when there is something to submit and enabled if ($show_top_submit_button == true) { ?> <div class="buttonRow forward"><?php echo zen_image_submit(BUTTON_IMAGE_ADD_PRODUCTS_TO_CART, BUTTON_ADD_PRODUCTS_TO_CART_ALT, 'id="submit1" name="submit1"'); ?></div> <br class="clearBoth" /> <?php } // show top submit ?> <?php if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) { ?> <div id="productsListingTopNumber" class="navSplitPagesResult back"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></div> <div id="productsListingListingTopLinks" class="navSplitPagesLinks forward"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, zen_get_all_get_params(array('page', 'info', 'x', 'y', 'main_page'))); ?></div> <br class="clearBoth" /> <?php } ?> <?php /** * load the list_box_content template to display the products */ //require($template->get_template_dir('tpl_tabular_display.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_tabular_display.php'); require($template->get_template_dir('tpl_columnar_display.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_columnar_display.php'); ?> <?php if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) { ?> <div id="productsListingBottomNumber" class="navSplitPagesResult back"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></div> <div id="productsListingListingBottomLinks" class="navSplitPagesLinks forward"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, zen_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></div> <br class="clearBoth" /> <?php } ?> <?php // only show when there is something to submit and enabled if ($show_bottom_submit_button == true) { ?> <div class="buttonRow forward"><?php echo zen_image_submit(BUTTON_IMAGE_ADD_PRODUCTS_TO_CART, BUTTON_ADD_PRODUCTS_TO_CART_ALT, 'id="submit2" name="submit1"'); ?></div> <br class="clearBoth" /> <?php } // show_bottom_submit_button ?> </div> <?php // if ($show_top_submit_button == true or $show_bottom_submit_button == true or (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != 0 and $show_submit == true and $listing_split->number_of_rows > 0)) { if ($show_top_submit_button == true or $show_bottom_submit_button == true) { ?> </form> <?php } ?>

Does anyone see any glaring issues as to why the products display randomly? I could really use some guidance from the ZC aficionados here...appreciate your help!

3 Dec 2007, 2:57 AM
#2
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,684
Plugin Contributions:
0

Re: Product sort order doesn't work- products display randomly!

They display randomly because that is how those displays are designed.

Please do not PM for support issues: a private solution doesn't benefit the community.

Be careful with unsolicited advice via email or PM - Make sure the person you are talking to is a reliable source.

3 Dec 2007, 3:21 PM
#3
ajshim avatar

ajshim

New Zenner

Join Date:
Dec 2007
Posts:
5
Plugin Contributions:
0

Re: Product sort order doesn't work- products display randomly!

Hey Kim, what do you mean by that? I simply want my category index pages to be sorted by sort ID.

3 Dec 2007, 3:40 PM
#4
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Product sort order doesn't work- products display randomly!

To change display order in category listing you need to edit:

-Configuration> Product Listing > Display Product Listing Default Sort Order

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

3 Dec 2007, 4:29 PM
#5
ajshim avatar

ajshim

New Zenner

Join Date:
Dec 2007
Posts:
5
Plugin Contributions:
0

Re: Product sort order doesn't work- products display randomly!

To change display order in category listing you need to edit:

-Configuration> Product Listing > Display Product Listing Default Sort Order

I set this value to 2a but that didnt seem to work.

FYI heres the page I'm talking about: http://www.aplombclothing.com/store/index.php?main_page=index&cPath=1

3 Dec 2007, 4:32 PM
#6
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Product sort order doesn't work- products display randomly!

Intersting, since your site seems to sort by random.

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

3 Dec 2007, 4:53 PM
#7
ajshim avatar

ajshim

New Zenner

Join Date:
Dec 2007
Posts:
5
Plugin Contributions:
0

Re: Product sort order doesn't work- products display randomly!

yeah I'm thinking my tpl_modules_product_listing.php is messed up. I think this module is what generates the content on the page but then again I don't really know much about PHP ... any help would be great

3 Dec 2007, 4:55 PM
#8
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Product sort order doesn't work- products display randomly!

I suspect this line:

			 				$new_products = $db->ExecuteRandomMulti($listing_sql, MAX_DISPLAY_NEW_PRODUCTS);

Check the default template, see if they have it there.

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

4 Dec 2007, 2:13 AM
#9
ajshim avatar

ajshim

New Zenner

Join Date:
Dec 2007
Posts:
5
Plugin Contributions:
0

Re: Product sort order doesn't work- products display randomly!

Yes it appears that the > ExecuteRandomMulti($listing_sql, MAX_DISPLAY_NEW_PRODUCTS); function is causing my store to break. I tried changing this to > Execute($listing_sql, MAX_DISPLAY_NEW_PRODUCTS); but this doesn't seem to work either. Does anyone understand how this function works?

4 Dec 2007, 2:16 AM
#10
ajeh avatar

ajeh

Oba-san

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

Re: Product sort order doesn't work- products display randomly!

The Centerboxes are designed to be random sort orders ...

The Listings each have their own settings for the display that you can configure on each of the Listing settings ...

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!