Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Simple attributes sorting


jampjamp

Recommended Posts

Hello, this problem is well known, but i would rather prefer to avoid installing any addons. I think it's doable by simple change in query.

My problem is that in attribute list they are shown by ID so if I'll add it like

1 ID = aaa

2 ID = ccc

3 ID = ddd

Then everything is shown right, but if I'll add later 4 ID = bbb it won't be shown between 1 and 2 ID's.

I guess it's all about query in product_info.php

Quote

$products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'");

So i'm trying to add somewhere

Quote

ORDER BY `products_options_values`.`products_options_values_name` ASC

But i'm not sure where to put it right cause this query is a little bit complicated. And actually i'm not sure if this "order by..." is correct because it looks like those tables are not recognized?

Quote

1054 - Unknown column 'products_options_values.products_options_values_name' in 'order clause'

 

I've tried also something like that:

Quote

    $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' ORDER BY " . TABLE_PRODUCTS_OPTIONS_VALUES_NAME ." FROM " . TABLE_PRODUCTS_OPTIONS_VALUES . " ASC");

But it causes an error 1064 (SQL Syntax)

Link to comment
Share on other sites

@jampjamp Try  
find this 
 

 $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$_GET['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'");

replace it with this  

 

$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$_GET['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . " ' ORDER BY  pov.products_options_values_name ASC"); 

 

BR
Omar

Get the latest Responsive osCommerce CE (community edition) here .

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...