Created
June 19, 2017 22:04
-
-
Save mehdichaouch/1c4a61486553bb257a2a4be4c3ed1ec8 to your computer and use it in GitHub Desktop.
Magento - jQuery function to sort configurable product attribute options by value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery.fn.sortOptionsByValue = function(){ | |
jQuery(this).each(function(){ | |
var op = jQuery(this).children("option"); | |
op.sort(function(a, b) { | |
return a.value > b.value ? 1 : -1; | |
}); | |
return jQuery(this).empty().append(op).val('').attr({selected: 'selected'}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment