OUR PHONE NUMBER: +6011 - 354 88278
 
Sebarang Pertanyaan sila Whatsapp Kami di +6011-354 88278

whatsapp

Display newly added products first in Category of Eshop

Display newly added products first in Category of Eshop

Times Read: 216

Display newly added products first in Category of Eshop

Eshop doesn’t have settings to show newly added products to show on top of the list in a category. This can be achieved by changing a simple file or you can say a simple customization.

Fire up your FTP and navigate to /catalog/controller/product and open up category.php in your favourite editor. Find the part, most commonly in line 21 and edit the following code


Eshop-category-ordering-by-date-added


Original code:

if (isset($this->request->get[‘sort’])) {
$sort = $this->request->get[‘sort’];
} else {
$sort = ‘p.sort_order’;
}


Change it to:

if (isset($this->request->get[‘sort’])) {
$sort = $this->request->get[‘sort’];
} else {
$sort = ‘p.date_added’;
}


And it is sorting by date, we will need to change the order too. After the above code block, in line 27 you will see the following code block to change the order.


Original Code:

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


Change it to:

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

Fire up your FTP and navigate to /catalog/model/catalog/ and open up product.php in your favourite editor. Find the part, most commonly in line 169 and edit the following code

Original Code:

if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model')

Change it to:

[if ($data['sort'] == 'p.date_added' || $data['sort'] == 'p.model')

Original Code:

$sql .= " DESC, LCASE(pd.name) DESC";]]>

Change it to:

$sql .= " DESC, LCASE(p.date_added) DESC";]]>

Original Code:

$sql .= " ASC, LCASE(pd.name) ASC";]]>

Change it to:

$sql .= " ASC, LCASE(p.date_added) DESC";]]>

Original Code:

ORDER BY p.sort_order]]>

Change it to:

ORDER BY p.date_added]]>

        

That’s it, then your newly added products will shown on top. This customization works well with Eshop 3 versions.


Alternatively, if you want to sort by price, you can use the p.price instead of p.date_added in the above code.

Do let us know if you encounter any problem.

Update : 09-01-2023 Jan 2023

Write Comment

LATEST NEWS