Jump to content

pagination page prices-drop.php


Recommended Posts

Sur la page prices-drop.php (promotions), la pagination prend en compte tous les produits, au lieu de ceux en promotion uniquement.

Apparemment juste un petit oubli dans la requête qui compte les produits

Remplacer (ligne 1089 environ, fichier /Classes/Product.php)

if ($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).’)’).’

)’;
$result = Db::getInstance()->getRow($sql);
return intval($result[’nb’]);
}


par

if ($count)
{
$sql = ‘
SELECT COUNT(DISTINCT p.`id_product`) AS nb
FROM `’._DB_PREFIX_.’product` p
WHERE p.`active` = 1
AND (`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.`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).’)’).’

)’;
$result = Db::getInstance()->getRow($sql);
return intval($result[’nb’]);
} 


Mis sur le bug tracker

Link to comment
Share on other sites

  • 4 weeks later...

merci pour cette contrib ça marche nikel chez moi aussi, enfin ça retire les pages fantôme ce qui est déjà plus que bien :).
par contre je n'ai qu'un produit par page pour 3 produits en promos j'ai 3 pages, est ce que vous avez une idée pour en afficher plusieurs par pages?
d'avance merci

Link to comment
Share on other sites

Bonjour
J'ai testé et ca ne fonctionne pas chez moi , mais j'ai trouvé une solution grâce à toi ;-P

if ($count)
       {
           $sql = '
           SELECT COUNT(DISTINCT p.`id_product`) AS nb
           FROM `'._DB_PREFIX_.'product` p
           WHERE p.`active` = 1
           AND (`reduction_price` > 0 OR `reduction_percent` > 0)
     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).')').'
           )';
           $result = Db::getInstance()->getRow($sql);
           return intval($result['nb']);
       }



De cette manère j'ai plus de souci

Link to comment
Share on other sites

  • 2 months later...

Si vous avez une ancienne version :

J'ai effectué cette correction qui fonctionne chez moi

Fichier Classes/Product.php

ligne 996 environ

J'ai remplacé ceci :

       if ($count)
       {
           $result = Db::getInstance()->getRow('
           SELECT COUNT(`id_product`) AS nb
           FROM `'._DB_PREFIX_.'product`
           WHERE `reduction_price` > 0
           OR `reduction_percent` > 0
           AND `active` = 1');
           return intval($result['nb']);
       }
       $currentDate = date('Y-m-d');



par ceci :

    if ($count)
       {
           $result = Db::getInstance()->getRow('
           SELECT COUNT(`id_product`) AS nb
           FROM `'._DB_PREFIX_.'product`
           WHERE (`reduction_price` > 0 OR `reduction_percent` > 0)
       '.((!$beginning AND !$ending) ?
           'AND (`reduction_from` = `reduction_to` OR (`reduction_from` <= \''.$currentDate.'\' AND `reduction_to` >= \''.$currentDate.'\'))'
       :
           ($beginning ? 'AND `reduction_from` <= \''.$beginning.'\'' : '').($ending ? 'AND `reduction_to` >= \''.$ending.'\'' : '')).'
           AND `active` = 1
           ');
           return intval($result['nb']);
       }
       $currentDate = date('Y-m-d');



Et je n'ai plus le problème de pagination

Link to comment
Share on other sites

  • 3 months later...

Bonjour,

J'ai effectivement fait un copier/coller pour corriger le bug et comme je travaille avec DW je vois bien que le code ne s'affiche pas comme il faut concernant la coloration syntaxique. Je remarque que dans ce code il y a des ` au lieu de ' et je pense qu'il faut les changer mais pas évident de savoir lesquels en plus de pas être certaine de mon affaire.

Quelqu'un peut me dire lesquels changer ou bien donner le code avec les bons '?


Merci de votre aide

Link to comment
Share on other sites

  • 3 weeks later...
  • 6 months later...
Guest
This topic is now closed to further replies.
×
×
  • Create New...