Admin Catalog Product listing default sort order to latest inserted product

OpenCart Product listing default sort order is as per product name, and you can sort them with product name ASC or DESC, Model ASC or DESC, price ASC or DESC, quantity ASC or DESC and Status ASC or DESC just by clicking on the listing of the table heading.

Opencart Product listing by product_id

But if you want to sort as per the latest inserted product then you need to do some code changes in default file which is not good but requirements always come first. (OcMod coming soon)

Find the following lines of code in admin\controller\catalog\product.php:

if (isset($this->request->get['sort'])) {
    $sort = $this->request->get['sort'];
} else {
    $sort = 'pd.name';
}

if (isset($this->request->get['order'])) {
    $order = $this->request->get['order'];
} else {
    $order = 'ASC';
}

Replace with the following lines of code:

if (isset($this->request->get['sort'])) {
    $sort = $this->request->get['sort'];
} else {
    $sort = 'pd.product_id';
}

if (isset($this->request->get['order'])) {
    $order = $this->request->get['order'];
} else {
    $order = 'DESC';
}

With this, the product listing will be listed with the latest product inserted by default, and click on table titles as per your req

Previous articleTwig Template coming in OpenCart 2.3
Next articleThe directory catalog/controller/product is not allowed to be written to – Opencart error

LEAVE A REPLY

Please enter your comment!
Please enter your name here