PHP Prestashop Web Development

Prestashop – How To Change Home Feature Product Deafult Sorting in PHP

By default Prestashop Home Feature product module is sorted by position. If you would like to change it to sort by date (Latest products show first), you need to change the homefeatured.php under ‘modules’ –> ‘homefeatured’. Before you do the following changes, please make sure you make a backup in case something goes wrong.

Let’s go to line 130 of homefeatured.php (version 1.8.0)

[js]
HomeFeatured::$cache_products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 8), ‘position’);
[/js]

Now, replace ‘position’ to ‘date_upd’, ‘DESC’ so it should look like this:

[js]
HomeFeatured::$cache_products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 8), ‘date_upd’, ‘DESC’);
[/js]

DONE! Please remember not to use the ‘Randomize ‘ option in the back office!

You may ask ‘Hey, Prestashop has a new product module. Why do I bother?’ Since the release of Prestashop 1.6, we have encountered multiple problems with New Product Module. Usually it cannot pick up the new products uploaded by administrator so we used the Home Featured Products as a backup plan. If the New Product module doesn’t work, you know what to do then.

If you have any questions, please leave a comment below.

Views (557)

The following two tabs change content below.