Magento Sort Attribute by Decimal not Alphanumerically

后端 未结 6 1687
刺人心
刺人心 2021-02-05 22:08

So I\'ve Googled like crazy to try and find a solution to this problem that actually works properly but have come up empty handed.

When using the Sort By function on a

6条回答
  •  悲&欢浪女
    2021-02-05 22:39

    Sorry, I'm a little late to the discussion. As I'm adverse to implementing code solutions when it isn't strictly necessary, I tried to think of an easier solution. I came up with the following.

    Example problem sorting Original sorting order: 10.0", 10.5", 14.0", 8.0", 8.5"

    Given that the list of numbers is sorted alphanumerically, I deduced that adding offsetting space characters (" ") before the 8s in my example above should result in the correct ordering. It did. This was the result.

    Example correct sorting New sorting order: 8.0", 8.5", 10.0", 10.5", 14.0"

    In the OP, Adam might have simple been able to replace "9kg" with " 9kg".

    By extension, if the numbers in question range from ones values to hundreds values, the ones values would have 2 leading spaces, the tens values would have 1 leading space, etc.

提交回复
热议问题