Jump to content


Corporate Sponsors


Latest News: (loading..)

* * * * * 2 votes

Product listing sort order


176 replies to this topic

#141 christianbright

  • Community Member
  • 103 posts
  • Real Name:Christian
  • Gender:Male
  • Location:Ohio

Posted 29 January 2010, 21:55

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!

#142 spooks

  • Community Member
  • 7,017 posts
  • Real Name:Sam
  • Gender:Male
  • Location:UK

Posted 29 January 2010, 22:44

View Postchristianbright, on 29 January 2010, 21:55, said:

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://forums.oscommerce.com/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.

#143 Peter M

  • Community Member
  • 52 posts
  • Real Name:Peter Milner
  • Gender:Male
  • Location:South West UK

Posted 02 March 2010, 17:30

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.

#144 byteeater

  • Community Member
  • 1 posts
  • Real Name:Rijal Fahmi M

Posted 26 May 2010, 08:24

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.

Edited by byteeater, 26 May 2010, 08:25.


#145 zstudios

  • Community Member
  • 2 posts
  • Real Name:Paul S.

Posted 22 July 2010, 16:49

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.

#146 whitewolfspirits

  • Community Member
  • 60 posts
  • Real Name:White
  • Gender:Male

Posted 27 November 2010, 02:52

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


#147 forummaker

  • Community Member
  • 95 posts
  • Real Name:Ken
  • Gender:Male
  • Location:USA

Posted 07 March 2011, 00:43

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://forums.oscommerce.com/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.

#148 forummaker

  • Community Member
  • 95 posts
  • Real Name:Ken
  • Gender:Male
  • Location:USA

Posted 21 March 2011, 21:52

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.

#149 edensan

  • Community Member
  • 22 posts
  • Real Name:Edwin

Posted 19 July 2011, 21:30

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

Edited by edensan, 19 July 2011, 21:40.


#150 NikoLewman

  • Community Member
  • 1 posts

Posted 11 September 2011, 21:16

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?

#151 peteravu

  • Community Member
  • 312 posts
  • Real Name:peter avu
  • Gender:Male

Posted 28 November 2011, 21:53

I know this thread is about product listing. But I need to sort the shopping cart after product name and then sort after attribute name? I can’t find out how to do . I use 2.3.1.

#152 cyberworlukltd

  • Community Member
  • 2 posts
  • Real Name:RobertPattinson
  • Gender:Male

Posted 29 November 2011, 09:31

Spooks, you are the Best

I did install the Ultimate SEO URLs contrib a while back. When I turn that off, my sort order problem goes away!!! Thanks so much for your help in pointing that out to me. I have not found the fix yet, but I see there are several versions after the one I installed, so it may be in one the new ones or in the thread somewhere. I guess will have to go find it.

Thanks again

Edited by cyberworlukltd, 29 November 2011, 09:35.


#153 oxwivi

  • Community Member
  • 223 posts
  • Real Name:Oxwivi Oxwil

Posted 12 March 2012, 10:00

I used Easy Populate to restore products back to osCommerce, but I want the latest models to show first. But there was a couple issues that made it difficult to achieve using the latest-first modification mentioned in the first page:
  • Since all of the products were restored from backup, all of the product's date added are exactly the same. So they sorted by the names.
  • The names, or rather, there are no names. We just copy the model number in the name field, and they go A-01, A-02, etc. With the higher numbers obviously being the latest.
So I did this:
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, p.products_model";
	    } else {
But it doesn't take care of the latest model issue. How do I sort by date and models?

#154 spooks

  • Community Member
  • 7,017 posts
  • Real Name:Sam
  • Gender:Male
  • Location:UK

Posted 12 March 2012, 10:38

View Postoxwivi, on 12 March 2012, 10:00, said:

all of the product's date added are exactly the same

It sounds like you have no data in your database related to the ordering you want, so its impossible to re-order that way.

I would look at modifying Easy Populate so it uses the original content for 'date added' instead of altering it, have you looked at the Easy Populate thread on this?
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.

#155 oxwivi

  • Community Member
  • 223 posts
  • Real Name:Oxwivi Oxwil

Posted 12 March 2012, 13:01

View Postspooks, on 12 March 2012, 10:38, said:

It sounds like you have no data in your database related to the ordering you want, so its impossible to re-order that way.

I would look at modifying Easy Populate so it uses the original content for 'date added' instead of altering it, have you looked at the Easy Populate thread on this?
Well, it maybe my fault that I did not keep the original data, but that does not solve the issue. I use EP to add multiple products at once, and that's another scenario with the same issue.

As a solution, I want to sort first with date, then with models. How can I do that?

#156 spooks

  • Community Member
  • 7,017 posts
  • Real Name:Sam
  • Gender:Male
  • Location:UK

Posted 12 March 2012, 13:24

Sorry, I `m not clear, does not your order by p.products_date_added DESC, p.products_model sort by model, your issue being all the dates are the same.

PS If you has auto backup installed (see signature) you could have gone back easily.
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.

#157 oxwivi

  • Community Member
  • 223 posts
  • Real Name:Oxwivi Oxwil

Posted 12 March 2012, 14:46

Well, I don't understand it myself. Is it sorting by models ascending or descending? Currently, the list goes A-01, A-02, and so on. If I add A-04 to A-10, I want it to go A-10, A-09, A-08 and so on till A-01.

#158 spooks

  • Community Member
  • 7,017 posts
  • Real Name:Sam
  • Gender:Male
  • Location:UK

Posted 12 March 2012, 15:07

So are your saying you want is sorted ascending for alphabetical values, but descending for any subsequent numerical?
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.

#159 oxwivi

  • Community Member
  • 223 posts
  • Real Name:Oxwivi Oxwil

Posted 12 March 2012, 15:33

I want to sort the whole value descending. There is no need to specifically sort the alphabets differently.

#160 spooks

  • Community Member
  • 7,017 posts
  • Real Name:Sam
  • Gender:Male
  • Location:UK

Posted 12 March 2012, 15:49

Could you check you're using the query you think you are by adding at the bottom of product_listing.php just before the final ?>

 echo '<hr>' . $listing_sql . '<hr>';


and saying what is shows.
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.