cartridge
cartridge copied to clipboard
Orderable product options
The dropdown list with product variations on the product page is unsorted. I have product variations which are numbers, so it is not a localization or NLS issue (the site is in russian) Attached a picture of dropdown list and a picture from admin showing product options (properly sorted when I click on "name" column header)


We basically need a way to sort the options in the admin. Don't think it will be too hard to implement, I'm just unsure of the best interface for doing it.
"...to sort the options in the admin"???
From my point of view it is important to get them sorted in the dropdown lists on the product page. In the admin - somewhere in the admin there should be a way to specify "how to sort the dropdown list". I can imagine following variants: -sort by name ascending -sort by name descending -add a new, hidden field, sort_order, and then choose in admin "sort by sort_order, ascending"
I think, the first two variants can be implemented without big efforts...
An admin user should be able to control the order of the options by going into the admin and sorting them in a drag/drop interface.
With that in place, all the other approaches are redundant. As simple as they may be, they'd only be short-term so there's no point in adding them.
"An admin user should be able to control the order of the options by going into the admin and sorting them in a drag/drop interface." - ok, and the implementation of it could be, for example, a hidden field "sort_order" Alternatively... do you mean the same sort mechanism as for "normal" pages?
Yes there'd be a hidden sort field. The way pages work isn't alternative, it's the same thing - hidden sort field with drag/drop ordering in the admin.
Anyway, for my purposes a plain vanilla "sort by name" will be enough - is it possible to add it quickly? If not - what is the best place/best way to have "sort by name" in my project? (a dirty, or not so dirty hack?)
Put one line of JavaScript into the product template.
Jquery to sort the first option. You can modify this to use wildcards if needed http://api.jquery.com/attribute-starts-with-selector/
$("#id_option1").html($("#id_option1 option").sort(function (a, b) {
return a.text == b.text ? 0 : a.text < b.text ? -1 : 1
}));
manually sorting products in the admin backend would be really, really, really nice. could work the same way as with pages. if theres is paging on the products site one drop area at the top and one at the bottom to drag and drop the item to the next page, could work.