Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Product Listing


muttsnuts

Recommended Posts

I have recently added a lot of products to my shop but in the catagory listing they are all over the place in terms of how they are listed.

 

Quite simply I wish all my products to be listed by price in decending order - i.e highest price to lowest.

 

Please help, I thought I sorted this long ago but alas not.

 

Thanks

 

P.S I have searched but did not find a solution, possibly using wrong earch terms.

Link to comment
Share on other sites

Line 191 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;
	}
  }
}

 

Change pd.products_name to p.products_price. This should by default list products in order by price.

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

Line 191 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;
	}
  }
}

 

Change pd.products_name to p.products_price. This should by default list products in order by price.

 

I tried your suggestion but get the following error when I click a catagory:

 

1054 - Unknown column 'pd.products_price' in 'order clause'

 

select p.products_image, pd.products_name, p.products_quantity, p.products_weight, p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from products_description pd, products p left join manufacturers m on p.manufacturers_id = m.manufacturers_id, products_to_categories p2c left join specials s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '1' and p2c.categories_id = '28' order by pd.products_price limit 0, 20

 

Any Ideas?

Link to comment
Share on other sites

I tried your suggestion but get the following error when I click a catagory:

 

1054 - Unknown column 'pd.products_price' in 'order clause'

 

select p.products_image, pd.products_name, p.products_quantity, p.products_weight, p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from products_description pd, products p left join manufacturers m on p.manufacturers_id = m.manufacturers_id, products_to_categories p2c left join specials s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '1' and p2c.categories_id = '28' order by pd.products_price limit 0, 20

 

Any Ideas?

 

I actually figured it out even though i'm not that smart. I remove the 'd' in 'pd.products_price' and it worked.

 

1 more question though how do I list by price in decreasing fasion - i.e most expensive to least expensive?

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...