Jump to content

[SOLVED]Sort products and pagination problem!


Franck_R

Recommended Posts

Hi,

When i choose "the lowest price" or the "highest price".
I have a problem when several pages are displayed (after two or three pages)

I give you some screens to explain my problem and i can see the same problem on others prestashop website.

The first price of the current page doesn't follow the last price of the previous page...

Regards,

Franck_R

26719_8GprgvWsXo5yeplbEs2W_t

Link to comment
Share on other sites

Hi,

My problem is solved.

There was a wrong calculation in the getProducts method, more exactly in the definition of 'orderprice' in the SELECT part.

(p.`price` * ((100 + (t.`rate`))/100) - IF((DATEDIFF(`reduction_from`, CURDATE()) <= 0 AND DATEDIFF(`reduction_to`, CURDATE()) >=0) OR `reduction_from` = `reduction_to`, IF(`reduction_price` > 0, `reduction_price`, (p.`price` * ((100 + (t.`rate`))/100) * `reduction_percent` / 100)),0)) AS orderprice




PS version 1.2.5
Thanks.

Link to comment
Share on other sites

  • 2 weeks later...
Hi,

My problem is solved.

There was a wrong calculation in the getProducts method, more exactly in the definition of 'orderprice' in the SELECT part.

(p.`price` * ((100 + (t.`rate`))/100) - IF((DATEDIFF(`reduction_from`, CURDATE()) <= 0 AND DATEDIFF(`reduction_to`, CURDATE()) >=0) OR `reduction_from` = `reduction_to`, IF(`reduction_price` > 0, `reduction_price`, (p.`price` * ((100 + (t.`rate`))/100) * `reduction_percent` / 100)),0)) AS orderprice




PS version 1.2.5
Thanks.



what file did you edit? can you explain what exactly have to do?
Link to comment
Share on other sites

It appears this bug has already been fixed in PrestaShop v1.3.1. It is on line 407 of classes/Category.php in PrestaShop v1.2.5 that should be changed from:

(p.price - IF((DATEDIFF(reduction_from, CURDATE()) <= 0 AND DATEDIFF(reduction_to, CURDATE()) >=0) OR reduction_from = reduction_to, IFNULL(reduction_price, (p.price * reduction_percent / 100)),0)) AS orderprice 



to:

(p.`price` * ((100 + (t.`rate`))/100) - IF((DATEDIFF(`reduction_from`, CURDATE()) <= 0 AND DATEDIFF(`reduction_to`, CURDATE()) >=0) OR `reduction_from` = `reduction_to`, IF(`reduction_price` > 0, `reduction_price`, (p.`price` * ((100 + (t.`rate`))/100) * `reduction_percent` / 100)),0)) AS orderprice

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

Okay. I think I fixed it. The problem was not with the reduced price calculations it was with the tax calculations. When a product was not associated with a tax and therefore 'p.id_tax = 0' the sql statement ended up with a NULL value for t.`rate`. So the price line in the sql statement in Category.php needs to be as follows to assign '1' if the return is NULL:


(p.`price` * IF(t.`rate`>0,((100 + (t.`rate`))/100),1) - IF((DATEDIFF(`reduction_from`, CURDATE()) <= 0 AND DATEDIFF(`reduction_to`, CURDATE()) >=0) OR `reduction_from` = `reduction_to`, IF(`reduction_price` > 0, `reduction_price`, (p.`price` * IF(t.`rate`>0,((100 + (t.`rate`))/100),1) * `reduction_percent` / 100)),0)) AS orderprice

Done, and done, Homies!

Link to comment
Share on other sites

  • 1 month later...
  • 5 weeks later...

Problem is, when you dont have prices in the main product, but by the attributes...

then you have to change the row by that

IF(
p.`price` = 0,
pa.`price`,
(p.`price` * IF(t.`rate`,((100 + (t.`rate`))/100),1) - IF((DATEDIFF(`reduction_from`, CURDATE()) <= 0 AND DATEDIFF(`reduction_to`, CURDATE()) >=0) OR `reduction_from` = `reduction_to`, IF(`reduction_price` > 0, `reduction_price`, (p.`price` * IF(t.`rate`,((100 + (t.`rate`))/100),1) * `reduction_percent` / 100)),0))
)
AS orderprice

Link to comment
Share on other sites

  • 3 months later...

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