Jump to content

Archived

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

mitchind

Sorting Attributes

Recommended Posts

Great idea

But does anybody know how to change the code so that it sorts by model number.

example 1 2 4 7 12 14 18 ect.

Dave

 

Yes, I was just looking for this very thing when I came across this thread, since Model number is my primary concern.

 

Because this therad wasn't what I was looking for, I hacked the file myself:

 

in catalog/index.php, lines 160-164:

       if ($column_list[$i] == 'PRODUCT_LIST_NAME') {
         $HTTP_GET_VARS['sort'] = $i+1 . 'a';
         $listing_sql .= " order by pd.products_name";
         break;
       }

 

to this:

       if ($column_list[$i] == 'PRODUCT_LIST_MODEL') {  //change here
         $HTTP_GET_VARS['sort'] = $i+1 . 'a';
         $listing_sql .= " order by p.products_model, pd.products_name"; //change here
         break;
       }

Share this post


Link to post
Share on other sites

I put this in place for myself because it was driving me crazy trying to get the product options displayed in the order I wanted. All the sorting contributions I came across were difficult to implement or changed a lot of code.

 

All I wanted was something that showed my options in order of price. Or at the very least showed them in the order I entered them.

 

It's a simple fix that takes less than a minute.

 

What it does...

First - sorts by price

Second - if price is same (or 0), it sorts based on the order that the option was entered.

 

File to change ... /catalog/product_info.php

 

Replace this line

$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)$HTTP_GET_VARS['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 . "'");

 

With this line

$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix, pa.products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['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 pa.options_values_price, pa.products_attributes_id");

 

Hope someone else will find this useful.

 

 

I'd like to have my attributes only appear in the order in which I enter them, I think this code will worked if tweaked a bit, currently I have sizes, some of which add to the base price and some of which subtract from the base

price. any help or tweaks would be greatly appreciated! and thanx in advance.

Share this post


Link to post
Share on other sites

Has anyone had this problem? - when this mod is applied the search returns nothing.

 

Am I the only one with this issue?

 

If not, can anyone post a MOD that fixes the search results issue.

Share this post


Link to post
Share on other sites

Has anyone had this problem? - when this mod is applied the search returns nothing

 

 

ISSUE SOLVED

Share this post


Link to post
Share on other sites

I've got some subcats where the "name" field has numeric values in it, and the default sort is as follows:

 

1

10

100

11

2

3

4

5

6

7

8

9

 

Is there a way around this? It should place 10 after 9 without having to enter 9 as "09". That has the potential to be confusing for customers.

 

Seems like it would be a fairly common question, but I've not seen anything on it yet. Perhaps I'm not searching the correct verbage. I'd really appreciate someone steering me in the right direction.

Share this post


Link to post
Share on other sites

Yes, I am still looking for a way sort option values by name.

This should be simple. Can a better-coder-than-me tell me if I can modify product_info.php to do this?

 

I need to control what appears first in the list of product options.

 

I tried installing McGrath's Sorter/Copier but I think maaaaaybe it isn't fully functional with the latest version of the cart. While I didn't receive any errors, and the copy function worked fine, the sorting feature did nothing. I uninstalled it.

 

Back to square 1.

 

Amy

 

Hi its great that people are providing these sorts of things, thanks.

 

I have tried this but get an error, when I have tried to add a new attribute to a product, any ideas whats happened ? Error below.

 

1136 - Column count doesn't match value count at row 1

 

insert into products_attributes values (null, '31', '4', '33', '0', '+')

 

[TEP STOP]

 

-----------

 

 

Thanks in advance, I've attached an image of my Product Options page, I've set the 'value price' at 0

 

Conrad

post-216146-0-63164600-1313925519_thumb.gif

Share this post


Link to post
Share on other sites

Works with Ajax Attributes Manager. Mine went crazy and started sorting opposite.

 

THANKS!!

Share this post


Link to post
Share on other sites

Hi its great that people are providing these sorts of things, thanks.

 

I have tried this but get an error, when I have tried to add a new attribute to a product, any ideas whats happened ? Error below.

 

1136 - Column count doesn't match value count at row 1

 

insert into products_attributes values (null, '31', '4', '33', '0', '+')

 

[TEP STOP]

 

-----------

 

 

Thanks in advance, I've attached an image of my Product Options page, I've set the 'value price' at 0

 

Conrad

 

 

YES - I had the same issue

 

http://forums.oscommerce.com/topic/379509-product-attribute-insert-error/page__fromsearch__1

 

http://forums.oscommerce.com/topic/379509-product-attribute-insert-error/page__fromsearch__1

Share this post


Link to post
Share on other sites

×