Skip to main contentSkip to footer

Admin Catalog Product listing default sort order to latest inserted product

Rupak Nepali
Share:
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

Comments

Join the conversation and share your thoughts

Leave a Comment

Your comment will be reviewed before publishing.

Be the first to comment on this post!

Innovation

Let's Make Something Amazing Together

We always provide our best creative ideas at the highest level. Tell us about your project and we will make it work.

InnovateBringing innovative solutions to complex problems
AutomateStreamlining processes through automation
DominateLeading the market with exceptional results
Build Smarter and Launch FasterEfficient development for rapid deployment