1

I have created an attribute that is used for sorting on the category pages. The sorting order is numeric. Expectation is that sorting order is:
1. 1
2. 2
3. 11

But the actual sort order is:
1. 1
2. 11
3. 2

Apparantly, Magento sorts on the first digit. Not on the complete integer.
How to effectuate the correct sort order?

3
  • Is this 2.2 or 2.3?
    – danronmoon
    Oct 30, 2019 at 20:31
  • I am sorry: 2.3.0. Is it a known 2.3 issue? Oct 30, 2019 at 20:32
  • You can use natsort Function of php after take that values in array. Oct 31, 2019 at 6:08

1 Answer 1

-1

You can use natsort Function of php after take that values in array.

Or

You can do this by custom Query as:

First add an order by clause at the end:

ORDER BY category_id

Treat it like an integer. There are a few ways to do this but I usually add a zero.

ORDER BY category_id + 0

Hope This will help You!!

1
  • Oscprofessionals can you implement that for me. At what cost? Oct 31, 2019 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.