You get a bonus - 1 coin for daily activity. Now you have 1 coin

How to change the default product sorting by price in OpenCart

Practice




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

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Running server side scripts using PHP as an example (LAMP)"

Terms: Running server side scripts using PHP as an example (LAMP)