Jump to content

[Solved] Nombre produit par page différent.


Recommended Posts

Bonjour a tous,

Il est possible de définir le nombre de produit dans la product-list via le back office de prestashop.
Mais est il possible de définir un nombre de produits différent dans newproducts.php, category.php et manufacturer.php
Car la navigation facette ne fonctionnant que dans category.php, j’ai une largeur de page bien plus importante sur newproduct.php et manufacturer.php, j’aimerai donc afficher plus de produits

C’est réalisable ça ?

J'ai trouvé sur le forum qu'il fallait aller chercher dans pagination.php, mais ça ne semble plus être applicable depuis la 1.4 :/


Merci d'avance pour votre aide.

Link to comment
Share on other sites

Merci a l'Équipe presta pour sa précieuse aide.

Il faut donc créer un fichier Controller selon la page dans votre dossier /override/controllers.

Exemple pour les pages manufacturer:

1. Créez ManufacturerController.php dans le dossier /override/controllers/
2. Et copiez collez ceci:

<?php
/*
* 2007-2011 PrestaShop 
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA 
*  @copyright  2007-2011 PrestaShop SA
*  @version  Release: $Revision: 6594 $
*  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/

class ManufacturerController extends ManufacturerControllerCore
{

   public function pagination($nbProducts = 10)
   {
       if (!self::$initialized)
           $this->init();

       $nArray = (int)(Configuration::get('PS_PRODUCTS_PER_PAGE')) != 10 ? array((int)(Configuration::get('PS_PRODUCTS_PER_PAGE')), 10, 20, 50) : array(10, 20, 50);
       asort($nArray);
       $this->n = 20; //Modifier ICI le nombre de produit par page pour les nouveaux produits.
       $this->p = abs((int)(Tools::getValue('p', 1)));
       $range = 20; /* how many pages around page selected */

       if ($this->p < 0)
           $this->p = 0;

       if (isset(self::$cookie->nb_item_per_page) AND $this->n != self::$cookie->nb_item_per_page AND in_array($this->n, $nArray))
           self::$cookie->nb_item_per_page = $this->n;

       if ($this->p > ($nbProducts / $this->n))
           $this->p = ceil($nbProducts / $this->n);
       $pages_nb = ceil($nbProducts / (int)($this->n));

       $start = (int)($this->p - $range);
       if ($start < 1)
           $start = 1;
       $stop = (int)($this->p + $range);
       if ($stop > $pages_nb)
           $stop = (int)($pages_nb);
       self::$smarty->assign('nb_products', $nbProducts);
       $pagination_infos = array(
           'pages_nb' => (int)($pages_nb),
           'p' => (int)($this->p),
           'n' => (int)($this->n),
           'nArray' => $nArray,
           'range' => (int)($range),
           'start' => (int)($start),
           'stop' => (int)($stop)
       );
       self::$smarty->assign($pagination_infos);
   }
}

  • Like 1
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...