Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Display Products By Price


Guest

Recommended Posts

I want to change the way my products are diaplayed. Instead of displaying them in alphebeitcal order, I would like to display them by price showing the cheapest in a catagory first.

 

I would imagine that someone with the know how would find this quite easy to do. I'm guessing it would be in catalog>includes>modules>product_listing but that is where my knowledge ends.

 

Can any one help me out with this one?

 

Thankyou in advance!

Link to comment
Share on other sites

I want to change the way my products are diaplayed. Instead of displaying them in alphebeitcal order, I would like to display them by price showing the cheapest in a catagory first.

 

I would imagine that someone with the know how would find this quite easy to do. I'm guessing it would be in catalog>includes>modules>product_listing but that is where my knowledge ends.

 

Can any one help me out with this one?

 

Thankyou in advance!

 

Hi,

 

There is of course a query which is performed to produce that listing. If you were to modify that query so that it ends with order by product_price for example, it should do as you want. Be sure to backup before you make any changes.

 

Be well,

 

Tina

If you're not having fun you're not doing it right

 

Teach a person to fish rather than give them a loaf of bread or however that saying goes.

Link to comment
Share on other sites

You may want to look at this contrib Shop by Price for starters.

 

I want to change the way my products are diaplayed. Instead of displaying them in alphebeitcal order, I would like to display them by price showing the cheapest in a catagory first.

 

I would imagine that someone with the know how would find this quite easy to do. I'm guessing it would be in catalog>includes>modules>product_listing but that is where my knowledge ends.

 

Can any one help me out with this one?

 

Thankyou in advance!

Link to comment
Share on other sites

I think the product listing module is for the admin interface, to add products to your catalog. You want this bit of code in index.php, in the catalog root:

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

 

Back up ypur index before you change anything! Then try changing it to 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)) ) {
? ? ?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 final_price";
? ? ? ? ?break;
? ? ? ?}

 

If that doesn't quite do it, you might also try changing the one line to if ($column_list[$i] == 'PRODUCT_LIST_PRICE') { to see if that does the trick.

 

Osc will give a variety of sort options as is, and users can change the way the sort happens on the index listing, thanks to this code. All you are trying to do here is set price ascending as the default. Remember to back up before you start fiddling with the code, I'm by no means a php expert, nor do I play one on tv, but this is my best guess as to how you would do that!

 

Jeremy

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...