Jump to content

Wrong pagination on prices_drop.php?


Recommended Posts

I'm managing a webshop for a friend (which we released only two days ago). He put up six products on sale, and I noticed that the pagination on prices_drop.php where incorrect. It displays the six products on sale, but paginates for the total product count!

I checked the Product::GetPricesDrop, and this is the code that gets the product count:

            $sql = '
           SELECT COUNT(DISTINCT p.`id_product`) AS nb
           FROM `'._DB_PREFIX_.'product` p
           WHERE p.`active` = 1
           AND p.`id_product` IN (
               SELECT cp.`id_product`
               FROM `'._DB_PREFIX_.'category_group` cg
               LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
               WHERE cg.`id_group` '.(!$cookie->id_customer ?  '= 1' : 'IN (SELECT id_group FROM '._DB_PREFIX_.'customer_group WHERE id_customer = '.intval($cookie->id_customer).')').'
           )';



Shouldn't this question contain a bit more in the Where-caluse, like in the question used to get the products in the same function:

WHERE (`reduction_price` > 0 OR `reduction_percent` > 0)
       '.((!$beginning AND !$ending) ?
           'AND (`reduction_from` = `reduction_to` OR (`reduction_from` <= \''.pSQL($currentDate).'\' AND `reduction_to` >= \''.pSQL($currentDate).'\'))'
       :
           ($beginning ? 'AND `reduction_from` <= \''.pSQL($beginning).'\'' : '').($ending ? 'AND `reduction_to` >= \''.pSQL($ending).'\'' : '')).'
           AND p.`active` = 1
           AND p.`id_product` IN [...]



I tested this, and it seems to work. Still learning prestashop though, so I just wanted to check if it looks OK. And if it's indeed a bug in PS, make sure it's fixed.

Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...

I had my prices-drop page showing 7 pages when in reality there was only 2.
This fix sorted it out for my site no problem.
I am using 1.2.4
Just replace the function with the code listed on the post I gave you and it will be sorted.

Link to comment
Share on other sites

  • 11 months later...

Arf this doesn't fix the problem for me... the thing that is unbelievable is that the pagination (based on Smarty $nbProducts) is right in 'new-products.php" (which is actually static public function getNewProducts in ./classes/Product.php)

Any idea ? Thanks

Link to comment
Share on other sites

×
×
  • Create New...