I have read many posts about this and so I combined a few to help those who have their attributes show up out of order. Like for me it was sizes. This will fix it no matter what order you put them in or they are in the database in OSCmax. One file different in regular Osc. Always back up first
First you must run a couple sql querys to add a new column in products_options_values
and products_options_values_to_options
First run this query:
ALTER TABLE products_options_values ADD COLUMN products_options_values_order_by INT UNSIGNED NOT NULL DEFAULT '0';
Then using phpmyadmin browse the table products_options_values and in the order_by column number your options in the order you want them to appear on the site. (corresponding to option name) 1 thru whatever
Then run this query
ALTER TABLE products_options_values_to_products_options ADD COLUMN order_by INT UNSIGNED NOT NULL DEFAULT '0';
Then browse table products_options_values_to_products_options and in the order_by column put your options in the order you want. In this table you will be referencing the products_options_value_ID If you do not know what your attribute option ID is you can look in admin under products attributes to get the ID # for that value or option.
Now change 2 files (3 if you are using the add multiple prods to cart contrib)
In admin/new_attributes_include.php
Find around line 58
$query2 = "SELECT * FROM products_options_values_to_products_options WHERE products_options_id = '$current_product_option_id' ORDER BY products_options_values_id DESC";
Replace with
$query2 = "SELECT * FROM products_options_values_to_products_options WHERE products_options_id = '$current_product_option_id' ORDER BY order_by DESC";
(The above sets order for attribute manager whether you use ASC or DESC is your choice)
In Catalog/includes/classes/pad_base.php Find around line 316
$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)$this->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 with
$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)$this->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_order_by ASC");
(This sets the order based on what you chose in the DB Order BY column on the product info page)
THATS IT! No matter what order you enter them in while in admin they always come out the way you set them up. If you are using add multiple prods to cart contribution with attributes on the product listing page you will also have to do the above change in the product_listing_multi_col.php
Now if you want to add the ajax attribute contrib which allows you to do everything on the product edit page including attributes instead of attribute manager it is easy since you do not have to first add the sort order contribution. You can however tweak it so they show in order on the admin side on the ajax contrib even though it is only aesthetic since they always come out right on the site side.
Hope you had a great Labor Day





LinkBack URL
About LinkBacks







Bookmarks