Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Product listing sort order


spooks

Recommended Posts

  • 4 weeks later...
  • Replies 177
  • Created
  • Last Reply
I went with a very simple approach..but this will ONLY work for you if you are NOT shipping by weight, and do not EVER plan to

I prefer to bend the cart to my will, with the least possible editing, its all about end result, simplicity and speed!

 

 

I use flat rate shipping so it works great for me...

 

I sort the products by weight

I assign the weight to be the order I want the products to display in.

in other words first product gets a weight of 10, second gets a weight of 20, ect...

going in 10's allows easy addition of products later...and also allows easy re-shuffling if you want it down the road..

 

one other make sure you up the max ship weight in the admin settings of your cart.. I use 50000

instead of 50, and then you need not worry about the cart saying....cant ship that, over the limit!

 

Good idea, you would need to edit product_listing though to stop is displaying the now meaningless weight.

 

hey, thats very good topic, I used that method with weight too.

 

Can you explain how to hide weight column and not lose sorting by weight method?

 

Thx in advance!

            _       _    _           
           | |     | |  | |          
_   _  __ _| |_   _| | _| |__   __ _ 
| | | |/ _` | | | | | |/ / '_ \ / _` |
| |_| | (_| | | |_| |   <| | | | (_| |
\__,_|\__, |_|\__,_|_|\_\_| |_|\__,_|
       __/ |                         
      |___/  

Link to comment
Share on other sites

I have two categories, one which i want to order in price and the other alphabetically, can this be done?

 

 

yes, just check on the current category & branch accordingly

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...

Obviously you must select the item to be sorted in admin to be displayed, otherwise your asking to sort by nothing!!!

 

So its hardly surprising when it doesnt work!!!

 

:rolleyes:

 

I changed those 2 lines in my /catalog/index.php and uploaded- but when I do a search I get the same sort order, it isn't sorting by price... any ideas?

 

I noticed that I didn't have a "case" for price in an area slightly higher up the index.php, so I added:

 

case 'PRODUCT_LIST_PRICE':
$select_column_list .= 'final_price, ';
break;

 

At line 203.

 

Just isn't working- anyone got any ideas why? I tried changing final_price to p.price (as that's the price field that's used in most of the code) but that didn't work either.

Link to comment
Share on other sites

Change default sort for search

 

 

 

If you look just a few post back (or forward depends on your forum view!!) you will see I gave code for search in november 18th

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

Hello Sam,

I have a simple question

 

if (PRODUCT_LIST_BUY_NOW) {
	$lc_text .= '<br><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $listing['products_name'] . TEXT_NOW) . '</a>'; 	 
	}

	$info_box_contents[$row][$col] = array('align' => 'center', 'params' => 'class="smallText" width="33%" valign="top"',
	'text' => $lc_text);

 

product_listing.php, around line 194

I would like to change the 'class="smallText" to another class (using new stylesheet), class="newText", then overwrite the file, clear cache, refresh the page but there is no change.

could you help me?

thank you for your time

Link to comment
Share on other sites

Hello Sam,

I have a simple question

 

if (PRODUCT_LIST_BUY_NOW) {
	$lc_text .= '<br><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $listing['products_name'] . TEXT_NOW) . '</a>'; 
	}

	$info_box_contents[$row][$col] = array('align' => 'center', 'params' => 'class="smallText" width="33%" valign="top"',
	'text' => $lc_text);

 

product_listing.php, around line 194

I would like to change the 'class="smallText" to another class (using new stylesheet), class="newText", then overwrite the file, clear cache, refresh the page but there is no change.

could you help me?

thank you for your time

oops, got it, edit the file in includes/modules not in includes/ :)

Link to comment
Share on other sites

Setting default order for advanced_search_result.php

 

To set the default search result order to date added

 

 

find(303)

 

  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';
   	$order_str = ' order by pd.products_name';
   	break;
 	}
}
 } else {

 

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)) ) {
$_GET['sort'] = 0 . 'd';              	
 $order_str = " order by p.products_date_added desc, pd.products_name";

 } else {

 

note variable names differ to other file.

 

If setting by existing headings, just use the change detailed in my OP. smile.gif

 

Tried amending /catalog/index.php as above, the only difference is I'm sorting by price- but it isn't working, the search results still seem to be pretty random, not ordered by price at all. Code I'm using is:

 

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

 

Any ideas?

Link to comment
Share on other sites

Just to add I also tried using p.products_price instead of p.price, but that didn't work either. It seems that whatever modifications are made to the file, the system just ignores them...

Link to comment
Share on other sites

Sort by price

/quote]

 

Why not simply use the code I provided in my OP for sort by price on the index.php file?

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

Sort by price

/quote]

 

Why not simply use the code I provided in my OP for sort by price on the index.php file?

 

The reason I changed it to p.price was that I wanted to order the search results by price, not by products_name...

 

I did try using the code in your very first post in this thread but that didn't work either...

 

I've now also tried the code from the first post, i.e:

 

   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 . 'a';
         $listing_sql .= " order by p.products_price";
         break;
       }
     }
   } else {

 

But this doesn't work regardless of whether or not I use p.price or p.products_price or final_price... which chunk of code should I be using? I'm guessing there must be another area where something needs to be changed but no idea where it is...

Link to comment
Share on other sites

 

 

If code in the OP don`t work, its one of a few reasons

 

1. You havent enabled the price column in admin

2. You're using some odd version of osC, these mods work on ms2 to rc2a varients

3. Your making errors when you edit

4. Your failing to upload modded 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

If code in the OP don`t work, its one of a few reasons

 

1. You havent enabled the price column in admin

2. You're using some odd version of osC, these mods work on ms2 to rc2a varients

3. Your making errors when you edit

4. Your failing to upload modded files.

 

Well, the prices are showing for the products, so I assume the price column must be enabled?

 

I inherited this osC installation from a previous developer, I can't see anywhere where I can find out what version it is- I guess they must have removed that code. Any way i can find out?

 

The modified files are being uploaded and I must have made the edits many times now, but I can never get the sorting to work. Is there maybe anything on advanced_search_result.php that also needs changing?

Link to comment
Share on other sites

Editing wrong files!!

I inherited this osC installation from a previous developer, I can't see anywhere where I can find out what version it is- I guess they must have removed that code. Any way i can find out?

 

The modified files are being uploaded and I must have made the edits many times now, but I can never get the sorting to work. Is there maybe anything on advanced_search_result.php that also needs changing?

 

 

Perhaps you need to try reading a bit more!!, I refered you to the code for index.php as thats what you said you were editing, if your trying to alter search results its the code i gave for advanced_search_result.php, try checking what page does what & reading threads properly b4 jumping in to edit random files.

 

 

Docs http://www.oscommerce.info/kb/osCommerce

Oscommerce Road Map for the newbies http://www.oscommerce.com/forums/index.php?showtopic=307356

How Do I …? http://www.oscommerce.com/forums/index.php?showtopic=274968&hl=

How do I install a contribution http://www.oscommerce.com/forums/index.php?showtopic=343384&st=0#entry1432157

How to secure your site: http://www.oscommerce.com/forums/index.php?showtopic=313323

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

  • 3 weeks later...

Quick question. I removed the + and - signs and the sort order but I want to remove the ability for people to sort it themselves (remove the clickable link). How do I go about that? Thanks!

 

 

If you want to reomve the headings altogether I gave that in this post http://www.oscommerce.com/forums/topic/308798-product-listing-sort-order/page__view__findpost__p__1355844

 

 

To remove the sort function, find the line:

 

$lc_text = tep_create_sort_heading($_GET['sort'], $col+1, $lc_text);

 

and delete.

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

  • 1 month later...

Hi Spooks,

 

I am in the process of loading products onto my site and have discovered I need the ability to have different categories sorted in different ways. For example, in the spares categories, I need these to be sorted by part number (products_model) which is no problem as it's the default sort method I am using now. In other categories however, I need (and have yet to install) the sort number contribution as per the same sort method as the categories themselves.

 

What I need however, is the ability to select while creating and editing categories in the category definition, which of the several methods available, model, name, price, sort number etc. the category should be sorted by.

 

In your opinion, how much of a mod is this? also due to my not being overly proficient with php, I would really appreciate some help with it.

 

Cheers,

Peter.

Link to comment
Share on other sites

  • 2 months later...

hi, i guess i have some problem with sorting product by price, current code for sorting by product price:

 

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 . 'a';
         $listing_sql .= " order by final_price";          
         break;
       }
     }
   } else {
     $sort_col = substr($HTTP_GET_VARS['sort'], 0 , 1);
     $sort_order = substr($HTTP_GET_VARS['sort'], 1);
     $listing_sql .= ' order by ';
     switch ($column_list[$sort_col-1]) {
       case 'PRODUCT_LIST_MODEL':
         $listing_sql .= "p.products_model " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
         break;
       case 'PRODUCT_LIST_NAME':
         $listing_sql .= "pd.products_name " . ($sort_order == 'd' ? 'desc' : '');
         break;
       case 'PRODUCT_LIST_MANUFACTURER':
         $listing_sql .= "m.manufacturers_name " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
         break;
       case 'PRODUCT_LIST_QUANTITY':
         $listing_sql .= "p.products_quantity " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
         break;
       case 'PRODUCT_LIST_IMAGE':
         $listing_sql .= "pd.products_name";
         break;
       case 'PRODUCT_LIST_WEIGHT':
         $listing_sql .= "p.products_weight " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
         break;
       case 'PRODUCT_LIST_PRICE':
         $listing_sql .= "final_price " . ($sort_order == 'd' ? 'desc' : ''). ", pd.products_name";
         break;
     }
   }

 

it did work sorting product by price, but it is not only sorting product by price , it is sorting by manufacture first then by price you can see here:

 

http://www.gamezone.co.id/pc-component-memory-c-261_250.html?osCsid=e089c923a064f6abe2da94247fa621f3

 

thing that i want is to sort only by price ignoring product name,manufacturer or other parameter.

 

thanks, and anyone have idea for this?? cause i have search in the forum and i can't find the solution.

Link to comment
Share on other sites

  • 1 month later...

Thanks for this post. You have mentioned about sorting product atributes'topic. Can you provide a link to that? What I am looking is to have size attributes sorted by size in a desc order.

 

Thanks.

Link to comment
Share on other sites

  • 4 months later...

I want to sort by the product name still, but I want it descending. I changed the code like you suggested:

 

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

 

 

but it isn't changing the way they sort. Not sure if this works for what I need. When I click on a category, I want the products to be displayed in reversed alphabetical order. Am I doing something wrong?

,

White Wolf Spirits

Link to comment
Share on other sites

  • 3 months later...

Don't mean to jump in here if its the wrong place to ask this... but what is being discussed here sound similar to what I'm looking for.

I'm trying to randomize the product listing in categories... as I posted here:

http://www.oscommerce.com/forums/topic/370096-random-product-on-category-page

Is this possible at all? It's driving me crazy....

Thanks for any help.

That "Can" you're about to open... has worms!

Don't say I didn't worn ya.

n. pl. cans of worms Informal - A source of unforeseen and troublesome complexity.

Link to comment
Share on other sites

  • 2 weeks later...

Any suggestions on my last post???

Thanks.

That "Can" you're about to open... has worms!

Don't say I didn't worn ya.

n. pl. cans of worms Informal - A source of unforeseen and troublesome complexity.

Link to comment
Share on other sites

  • 3 months later...

Hi all,

 

I have ad the contri Easy Populate for 2.2

 

i want to sort on id is that possible?

 

greetz Edwin

 

 

edit:

i was looking for _ID and i want to sort on TABLE_HEADING_ID

 

low id first and so on

Link to comment
Share on other sites

  • 1 month later...

Hi Spooks,

Thank you for this really useful thread. I have just one noob question: will

 

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

 } else {

 

work also on updated products?

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...