Jump to content

Label/flag "new" on last day of product


zmora.vip

Recommended Posts

Hello,
I found a bug and Im almost sure it is in clear instalation of prestashop 1.7

If it is last day of "newest" limit days, prestashop dont add "new" label to product. For example if you set 45 days for "new product" life and one product life is 44 days and 2nd is 45 days then both are on list "new products" but only one got label/flag "new". Am i right? Can you help me to fix it? I think it need to be "<=" and it is "<" in function checking limit life of new flag.

image.png.cfe6b3eb4bc3810c85c16a257f2b708d.png
 

Edited by zmora.vip (see edit history)
Link to comment
Share on other sites

Thanks  @Piotr3qx 🍺 for find solution.

Problem is not in flag/label but in incorrect counting days for new products. If product is created in 1.01.2022 and "new" is for 3 days then it need to display in 1/2/3.01.2022 but not in 4.01.2022. Prestashop accept 4th day for listing but not for label. So label /flag was OK, but listing was incorrect.

in classes/Product.php line:2685

$sql->where('product_shop.`active` = 1');
        if ($front) {
            $sql->where('product_shop.`visibility` IN ("both", "catalog")');
        }
        $sql->where('product_shop.`date_add` > "' . date('Y-m-d', strtotime('-' . $nb_days_new_product . ' DAY')) . '"');

we need to add one day so:

$sql->where('product_shop.`active` = 1');
        if ($front) {
            $sql->where('product_shop.`visibility` IN ("both", "catalog")');
        }
        $sql->where('product_shop.`date_add` > "' . date('Y-m-d', strtotime('-' . $nb_days_new_product+1 . ' DAY')) . '"');

HAND ;)

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...