Jump to content

Unable to sort products by Date in product page Prestashop version 8.1.0


Recommended Posts

Hi, I recently got my website upgraded to 8.1.0 and problem is the oldest products are appearing on top. Alot of products are very old and we dont want them to appear on front page ( New Products module on main page). Is there any way I can set the order of products by date so that new products can appear first? I tried to find but found no such option, however in older prestashop 1.7 I was using this option to sort the products by date. Please help. Thanks

Link to comment
Share on other sites

Hi,

You have to edit code for this purpose, in modules/ps_newproducts/ps_newproducts.php

Find function getNewProducts and change the code to below one.

 

$newProducts = Product::getNewProducts(
                (int) $this->context->language->id,
                0,
                (int) Configuration::get('NEW_PRODUCTS_NBR'),
                false,
                'date_add'
            );

 

  • Like 1
Link to comment
Share on other sites

6 minutes ago, Matt Rix said:

Hi,

You have to edit code for this purpose, in modules/ps_newproducts/ps_newproducts.php

Find function getNewProducts and change the code to below one.

 

$newProducts = Product::getNewProducts(
                (int) $this->context->language->id,
                0,
                (int) Configuration::get('NEW_PRODUCTS_NBR'),
                false,
                'date_add'
            );

 

Thank you for your response, i will check and let you know the results. Thank you once again.

Link to comment
Share on other sites

20 hours ago, Matt Rix said:

Hi,

You have to edit code for this purpose, in modules/ps_newproducts/ps_newproducts.php

Find function getNewProducts and change the code to below one.

 

$newProducts = Product::getNewProducts(
                (int) $this->context->language->id,
                0,
                (int) Configuration::get('NEW_PRODUCTS_NBR'),
                false,
                'date_add'
            );

 

Hi, i made the changes and its working just fine. Thank you so much.

Link to comment
Share on other sites

Like I said, it worked perfect. I want same thing for "Featured Products" as well. If you or any one else can help in this regard, i would be grateful.

 

Regards,

 

21 hours ago, Matt Rix said:

Hi,

You have to edit code for this purpose, in modules/ps_newproducts/ps_newproducts.php

Find function getNewProducts and change the code to below one.

 

$newProducts = Product::getNewProducts(
                (int) $this->context->language->id,
                0,
                (int) Configuration::get('NEW_PRODUCTS_NBR'),
                false,
                'date_add'
            );

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...