how to change opencart's default product sorting by price
in the file /catalog/model/catalog/product.php
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model') {
$sql .= " ORDER BY p.price ASC , LCASE(" . $data['sort'] . ")";//p.new
} else {
$sql .= " ORDER BY p.price ASC ," . $data['sort'];//p.new
}
} else {
$sql .= " ORDER BY p.price ASC , p.sort_order";// p.new DESC
add p.price ASC if you want to sort from cheapest to most expensive
or p.new DESC to show new items first, but for new items only, first add a new field
Comments