Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Product listing sort order


spooks

Recommended Posts

If I understand that question correctly, I have an old trick I use in numbering my pics, and that is to use 3 digits.

 

photo001

photo002

photo003

and so on, as you will be fine up to 1000 pics, and they will be sorted by your default sort of alphabetically.

 

 

 

All my products are named by number, i just want it to list by number and not alphabetically, how do i do that?

 

Photo 1

Photo 2

Photo 3

 

 

Instead of

 

Photo 1

Photo 10

 

THANK YOU!

Link to comment
Share on other sites

  • Replies 177
  • Created
  • Last Reply

Its set in in admin & detailed in that contrib!!!

 

Search Results.

 

:rolleyes:

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

  • 2 weeks later...
OOPS, did you spot the deliberate mistake? It should be:

 

Replace with:

 

if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('^[1-8][ad]$', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) {
	  $HTTP_GET_VARS['sort'] = 0 . 'd';
	  $listing_sql .=  " order by p.products_date_added DESC, pd.products_name";
} else {

Thanks Spooks - *exactly* what I was looking for!! ;-)

Link to comment
Share on other sites

  • 2 weeks later...
This question keeps coming up & people seem to have trouble finding the answer in the forums, so I'll put this here to make it easy.

 

The product list order is by name as default, that is hard coded within index.php so you must change that to alter.

 

The product list sort order also depends on what was clicked last, you may have noticed that annoying '+' by 'product name' in the list heading, thats supposed to tell you that clicking on that or 'product name' will change list order on product name, similarly clicking on any other heading will order list by that column.

 

The code that sets the default order starts aroun 200 of index.php

 

 if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('^[1-8][ad]$', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) {
for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
if ($column_list[$i] == 'PRODUCT_LIST_NAME') {
$HTTP_GET_VARS['sort'] = $i+1 . 'a';
$listing_sql .= " order by pd.products_name";
break;

To sort by something else you must change 2 lines to the appropriate item

 

1.

if ($column_list[$i] == 'PRODUCT_LIST_NAME') {

 

change the PRODUCT_LIST_NAME to one of: PRODUCT_LIST_MODEL, PRODUCT_LIST_MANUFACTURER, PRODUCT_LIST_QUANTITY, PRODUCT_LIST_WEIGHT, PRODUCT_LIST_PRICE

 

2.

$listing_sql .= " order by pd.products_name";

 

change the pd.products_name to one of p.products_model, m.manufacturers_name, p.products_quantity, p.products_weight, final_price

 

If you wish to sort it reverse order you add DESC & change a to d to indicate order.

 

So if your wanting the default sort to be by price in descending order you would have:

 

if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('^[1-8][ad]$', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) {
for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
if ($column_list[$i] == 'PRODUCT_LIST_PRICE') {
$HTTP_GET_VARS['sort'] = $i+1 . 'd';
$listing_sql .= " order by final_price desc";
break;

 

Please dont confuse this with sorting product atributes, thats another subject & there is a post in tips dealing with it.

 

Hope that makes things clear.

 

:)

 

Maybe I am editing in the wrong lines, but I want the products to be listed in the order I upload them in the catagory. When I edit the lines from names to models, the names of the products disappear in the catagorie view. What can I do to fix this?

Link to comment
Share on other sites

Iether you are not editing the file as specified, or you have a TEMPLATE, all these tips apply to standard osC only

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

Someone asked 'how to remove the headings':

 

in includes/modules/product_listing.php

 

find(68)

 

	$list_box_contents[0][] = array('align' => $lc_align,
								'params' => 'class="productListing-heading"',
								'text' => ' ' . $lc_text . ' ');

replace with

 

	/* $list_box_contents[0][] = array('align' => $lc_align,
								'params' => 'class="productListing-heading"',
								'text' => ' ' . $lc_text . ' ');  */

 

 

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

  • 2 months later...

It's a mystery to me why the sort order was ever set to product name.

On a production site with thousands of products, new products get entered daily and you'll want the newer products to display on the first page.

 

 

first off I changed the

 

$HTTP_GET_VARS['sort'] = $i+1 . 'a';

to

$HTTP_GET_VARS['sort'] = $i+1 . 'd';

 

commented out

$listing_sql .= " order by pd.products_name";

/*$listing_sql .= " order by pd.products_name";*/

 

and added

$listing_sql .= " order by pd.products_id desc";

 

under

case 'PRODUCT_LIST_NAME':

 

commented out

$listing_sql .= " order by pd.products_name " . ($sort_order == 'd' ? 'desc' : '');

/* $listing_sql .= " order by pd.products_name " . ($sort_order == 'd' ? 'desc' : '');*/

 

and added

$listing_sql .= " order by pd.products_id " . ($sort_order == 'd' ? 'desc' : '');

 

--------------

Now the newer products display first. This works with multiple column formats as well as single column formats.

Link to comment
Share on other sites

It's always diificult to suit everyone, I'm sure if the default was product_id many would still complain its not what they want.

 

As many have this issue what would have been better would be sort order selectable within admin.

 

A word of caution with your edits, they will only work as long as Product Name is in the display list, also would'nt setting by date added be more appropriate (I detailed how ealier in this thread).

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

Does anyone know how and where to fix this problem I am having with the Sort Order?:

 

My pull down menu displays the following: "Product NameAPHA_ORDER" instead of just "Product Name".

 

And also the selector for "LIST_VIEW/THUMB_VIEW" is NOT displayed in a drop down button but just as a link.

 

I am using the following contributions: Additional Images v2.1.0, Product Listing Enhancements, Thumbnails & Manufacturer Headings V1.8, export_orders_to_csv_v22, PageHeaders_and_Subheaders and PageHeadersFix

 

On osCommerce v.2.2ms2 with MySQL 5.045.

 

Thank you!!

Link to comment
Share on other sites

This relates to Product Listing Enhancements, Thumbnails & Manufacturer Headings

 

please post in the correct thread & ensure you made all changes detailed to language files.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

Thank you for pointing me to the right place.

I had forgotten to place the following code in includes/languages/english/index.php:

 

Before the final ?>

 

Add:

 

define('TABLE_HEADING_DETAIL', 'Click For More');

define('TEXT_POA', ' P.O.A');

define('IMAGE_BUTTON_DETAILS', 'Product Details');

define('NUM_ORDER', ', Low to High');

define('APHA_ORDER', '');

define('REVERSE_ALPHA_ORDER', ', Reverse');

define('REVERSE_NUM_ORDER', ', High to Low');

define('DATE_ORDER', 'Date Added');

define('LIST_VIEW', 'List View');

define('THUMB_VIEW', 'Thumbnail View');

define('WEIGHT_ABRV', 'Kg');

 

Thank you very much.

Link to comment
Share on other sites

  • 3 weeks later...

Ok Ive been reading this thread and it seams like you all know what you are talking about! please help me; I have two Index (not talking about the one in includes/languages/English) i have changed my index.php but kept a second unchanged one on my pc for a backup. Basically what i have done is only keep (deleated everything else, apart from) the header, application top, column right (shopping cart), column left search bar, application bottom and footer. then where the main middle part of the page is I've added html. It looks great!!!! every else on my site works completely no problems, apart from the search bar (it finds nothing) because I have deleted all the code you are speaking about that organises the searches (silly me!)

 

so my question is can someone show me please where this search bar code starts and ends inside the index.php? ( just for the search bar)

 

 

my index php code now looks like this:

 

<?php

/*

$Id: index.php 1739 2007-12-20 00:52:16Z hpdl $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

require('includes/application_top.php');

 

// the following cPath references come from application_top.php

$category_depth = 'top';

if (isset($cPath) && tep_not_null($cPath)) {

$categories_products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");

$cateqories_products = tep_db_fetch_array($categories_products_query);

if ($cateqories_products['total'] > 0) {

$category_depth = 'products'; // display products

} else {

$category_parent_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$current_category_id . "'");

$category_parent = tep_db_fetch_array($category_parent_query);

if ($category_parent['total'] > 0) {

$category_depth = 'nested'; // navigate through the categories

} else {

$category_depth = 'products'; // category has no products, but display the 'no products' message

}

}

}

 

require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_DEFAULT);

?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html <?php echo HTML_PARAMS; ?>>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<title><?php echo TITLE; ?></title>

<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">

<link rel="stylesheet" type="text/css" href="stylesheet.css">

<style type="text/css">

<!--

.style1 {color: #FF9999}

.style2 {color: #FF3333}

-->

</style>

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">

<!-- header //-->

<?php require(DIR_WS_INCLUDES . 'header.php'); ?>

<!-- header_eof //-->

 

<!-- body //-->

<table width="100%" height="559" border="0" cellpadding="0" cellspacing="0">

<tr>

<td width="98%" height="559" align="left" valign="top"><table width="100%" height="559" border="0" cellpadding="2" cellspacing="0">

 

 

 

 

 

 

<td width="47" height="559"><html>

<title>HTML with PHP</title><body>

<h1>

<td width="220" rowspan="2" align="right" valign="top" bgcolor="#000000"><div align="left">

<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#CC0000">

<tr bgcolor="#000000" class="infoBoxHeading">

<td width="17%" bgcolor="#CC0000" class="infoBoxHeading style7 style15"><form action="http://www.example.com/shop/catalog/advanced_search_result.php"'>http://www.example.com/shop/catalog/advanced_search_result.php" method="get" name="quick_find" class="style5">

<p align="center" class="style7">

<input type="text" name="keywords" size="10" maxlength="30" style="width: 95px">

 

<input type="image" title=" Quick Find " src="button_quick_find.gif" alt="Quick Find" align="bottom" width="21" height="18" border="0">

<br>

<a href="http://www. example.com/shop/catalog/advanced_search.php" class="style7 style1 style1">Advanced Search</a> </p>

</form></td>

</tr>

<tr bgcolor="#000000" class="infoBoxHeading">

<td height="307" align="left" valign="top" bgcolor="#CC0000" class="headerNavigation style7 style15"><p align="left" class="style6"> </p>

<p align="left" class="style6 style2">A new firm is on the horizon... example is a design house with a fresh approach to ‘on-the-edge’ creations in clothing and bespoke design service in all art-forms. With all garments being exclusive and limited edition prints, each created by our talented artists, you’ll be sure to reward yourself with something unique and much sought after. </p>

<p align="left" class="style6 style2">Should you require a gift which is unique, a limited edition and dangerously sexy...then look no further than garments from example. Brilliant designs come as standard and we guarantee that you will not find any of our special items in any store, anywhere in the world!!</p>

<p align="left"><span class="style6 style2">Extraordinary designs, fresh ideas and total exclusivity....welcome to example! </span><br>

</p></td>

</tr>

<tr bgcolor="#990000">

<td height="74" align="center" valign="middle" bgcolor="#FF0055" class="orderEdit" font-family="Tahoma, Impact" font-size="12px" color="#000000" font-weight="bold" ><p class="style3"><a href="http://www. example.com/shop/catalog/shipping.php">Shipping & Returns</a><br>

<a href="http://www. example.com/shop/catalog/privacy.php">Privacy Notice</a><br>

<a href="http://www. example.com/shop/catalog/conditions.php">Conditions of Use</a><br>

<a href="http://www. example.com/shop/catalog/contact_us.php">Contact Us</a></span> </p>

</p></td>

 

</tr>

</table>

<p> <img src="SIG.jpg" width="120" height="88" hspace="100" vspace="20"></p>

</div></td>

<td width="740" rowspan="2" align="center" valign="middle" background="http://www. example.com/shop/catalog/images/BG.jpg"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="714" height="518">

<param name="movie" value="HOME.swf">

<param name="quality" value="high">

<embed src="HOME.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="714" height="518"></embed>

</object> </h1></td>

 

 

 

 

 

 

</table>

 

 

 

 

 

 

 

 

<!-- body_text_eof //-->

<td width="2%" align="right" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">

<!-- right_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>

<!-- right_navigation_eof //-->

</table></td>

</tr>

</table>

<!-- body_eof //-->

 

 

 

 

<!-- footer //-->

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

<!-- footer_eof //-->

<br>

</body>

</html>

<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Link to comment
Share on other sites

You seem to have got things wrong, index.php deals with product listing by category, for search standard the path is,

 

advanced_search.php accepts the data then advanced_search_result.php builds the query, then product_listing.php outputs the query having passed it through the split_page_results.php class for pagination

 

 

see where your search box links to!

 

Also your links are all wrong see http://www.oscommerce.com/forums/index.php?sho...c=330479&hl

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

oh you mean for the sid!? um well i was thinking I haven't change how they are written from the original os template. also i have tested to see if i can carry an item around the site with it remaining in my cart, but what if there are more than one person trying to buy things is this what you mean?

 

thanks sam

 

ben.

Link to comment
Share on other sites

thanks sam, i changed my links on purpose. I like people to see the finished product

 

 

My point is not where you link to, but your links cause loss of sid, with resulting failures, read the link i gave.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

I have a flash bar that runs through my site except for the first page that has html so it works with google. the flash buttons link like this: on (release) {getURL('http://www.darkink-womensclothing.com/shop/catalog/HOT.php');} this will kill the sid wont it! ?

 

lol I dint even know that there was a sid!

Link to comment
Share on other sites

if sid is lost at any time the application will consider they are a new visitor, so they would loose the cart content, suddenly find their logged out again or even get lost halfway through checkout!!

 

osC keeps the users sid between pages through use of the tep_href_link function, so all links must use tep_href_link to ensure the sid remains, you can circumvent this issue with 'Force Cookie Use' where since the sid is stored within the cookie if it is lost through any 'bad' code it can be picked up from there again.

 

So links with<a href="index.php">Back Home</a>are bad, you must use<a href="<?php echo tep_href_link(FILENAME_DEFAULT); ?>">Back Home</a>

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

even this

 

<a href="<?php echo tep_href_link("http://www. example.com/shop/catalog/advanced_search.php" class="style7 style1 style1"); ?>">Advanced Search</a>

 

get it right!

 

 

no, that should be:

 

<a href="<?php echo tep_href_link('advanced_search.php'); ?>" class="style7 style1 style1" >Advanced Search</a>

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

Ok I get you now sam, I see theres an extra php casing around it! making it like a proper php link and not just a crappy html it actually keep them like on file while they are shopping ok! wicked!!! well that is one of those terrible problems out of the way! im gona try on my flash buttons too! but the thing that is puzzleing me is why would the ostemplate be without these better links? i used this version : oscommerce-2.2rc2a

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...