Answer the question
In order to leave comments, you need to log in
How to sort by SKU (sku) in Opencart?
In the database, the SKU field has the varchar type, so sorting by article does not work correctly:
1,10,11,2,20,21
How to sort the article as a number?
1,2,10,11,20,21
Which query in /catalog/model/catalog/product.php should be changed?
Answer the question
In order to leave comments, you need to log in
I figured it out for those who are interested:
On 1.5.3.1
File /catalog/model/catalog/product.php
In this condition:
Add:
elseif ($data['sort'] == 'p.sku') {
$sql .= " ORDER BY CAST(" . $data['sort'] . " as unsigned)";
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question