Jump to content

Changing Pagination on product pages


jparkerbishop

Recommended Posts

Edit line 3 of pagination.php to change the dropdown values:

$nArray = intval(Configuration::get('PS_PRODUCTS_PER_PAGE')) != 10 ? array(intval(Configuration::get('PS_PRODUCTS_PER_PAGE')), 10, 20, 50) : array(10, 20, 50);



This code checks whether the products per page set on the Preferences > Products tab is 10. If it is, it displays 10, 20 and 50, otherwise it displays the products per page set on the Preferences > Products tab, then 10, 20 and 50.

  • Like 1
Link to comment
Share on other sites

$nArray = intval(Configuration::get('PS_PRODUCTS_PER_PAGE')) != 10 ? array(intval(Configuration::get('PS_PRODUCTS_PER_PAGE')), 10, 48, 92) : array(10, 48, 92);

That's the code I have changed, but it still has had no effect on the drop down menu? Could you please take a look and advise.

I have also tried changing the remaining '10' but this had no effect either.

Link to comment
Share on other sites

How many products are there on the page you are viewing? Only the options less than the current number of products will be displayed, so unless there are 49 or more products you will only see 10 as the option for products per page.

Link to comment
Share on other sites

Hi Rocky, I have set Preferences > products to 9 because my grid is 3 column, and then I want to change to 9, 18, 36.. I've changed a code to this:

$nArray = intval(Configuration::get('PS_PRODUCTS_PER_PAGE')) != 9 ? array(intval(Configuration::get('PS_PRODUCTS_PER_PAGE')), 9, 18, 36) : array(9, 18, 36);

also, I have 14 products displayed in one category.. but it's still give me option of 9 and 10 items only.. like something wrong with the code?

Link to comment
Share on other sites

  • 2 months later...

I need to copy classes/FrontController.php to override/classes/FrontController.php and then edit override/classes/FrontController.php ??

And what about override/classes/_FrontController.php?

Edit:

This is my file:
override/classes/FrontController.php

<?php

class FrontController extends FrontControllerCore
{
   public function pagination($nbProducts = 12)
   {
       if (!self::$initialized)
           $this->init();

       $nArray = (int)(Configuration::get('PS_PRODUCTS_PER_PAGE')) != 12 ? array((int)(Configuration::get('PS_PRODUCTS_PER_PAGE')), 12, 24, 36, 48, 60) : array(12, 24, 36, 48, 60);
       asort($nArray);
       $this->n = abs((int)(Tools::getValue('n', ((isset(self::$cookie->nb_item_per_page) AND self::$cookie->nb_item_per_page >= 12) ? self::$cookie->nb_item_per_page : (int)(Configuration::get('PS_PRODUCTS_PER_PAGE'))))));
       $this->p = abs((int)(Tools::getValue('p', 1)));
       $range = 2; /* 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);
   }
}



Its ok?

ps. My English is very weak but i understand very well ;]

Link to comment
Share on other sites

  • 10 months later...

Hi, i tried to change frontcontroller in overrides, like explained, but without success, it works but just when i enter the category, if i go to second page throught pagination. It displays me in dropdown these values 12,10,20,50. Any idea why ? I m using Prestashop version

1.4.6.2. Thanks in advance

Link to comment
Share on other sites

  • 2 months later...
  • 5 months later...

Edit line 3 of pagination.php to change the dropdown values:

 

 

$nArray = intval(Configuration::get('PS_PRODUCTS_PER_PAGE')) != 10 ? array(intval(Configuration::get('PS_PRODUCTS_PER_PAGE')), 10, 20, 50) : array(10, 20, 50);

 

 

This code checks whether the products per page set on the Preferences > Products tab is 10. If it is, it displays 10, 20 and 50, otherwise it displays the products per page set on the Preferences > Products tab, then 10, 20 and 50.

 

 

thanks

it worked perfect in PrestaShop™ 1.4.7.3

Edited by itrends (see edit history)
Link to comment
Share on other sites

  • 4 months later...
  • 7 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...