Jump to content

[Solved] Product Pagination (Using a value other than global)


Recommended Posts

Hello all! I have a problem which is similar to this topic that was solved:

 

http://www.prestasho...ng-to-category/

 

Unfortunately, the code that was provided does not work with what I have, and I do not know what version that person used for the solution. I'm currently using 1.5.4.0.

 

If there are any existing solutions, or if anyone knows how to solve this, please point me in the right direction.

 

Thank you!

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

This code piece is found in /classes/controller/FrontController.php (line 824 onward):

public function pagination($nbProducts = 10)
{
 if (!self::$initialized)
  $this->init();
 elseif (!$this->context)
  $this->context = Context::getContext();
 $nArray = (int)Configuration::get('PS_PRODUCTS_PER_PAGE') != 10 ? array((int)Configuration::get('PS_PRODUCTS_PER_PAGE'), 10, 20, 50) : array(10, 20, 50);
 // Clean duplicate values
 $nArray = array_unique($nArray);
 asort($nArray);
 $this->n = abs((int)(Tools::getValue('n', ((isset($this->context->cookie->nb_item_per_page) && $this->context->cookie->nb_item_per_page >= 10) ? $this->context->cookie->nb_item_per_page : (int)Configuration::get('PS_PRODUCTS_PER_PAGE')))));
 $this->p = abs((int)Tools::getValue('p', 1));

 

After this last line, you should add the solution given in the post you mentioned. Not sure if it works for you, but give it a try.

 

(N.B. the post uses a fixed category ID of '12'. This will probably need to be changed into the category you need to adjust yourself...)

 

Hope this helps,

pascal

  • Like 1
Link to comment
Share on other sites

Ah I've figured out the problem!

 

The line of code was using the variable "id_parent". I simply changed it to "id" and it works.

 

if($this->category->id==13){

$this->n = 10;

}

 

Replace the number to the appropriate category. Hope this will be useful to others!

Edited by xuthiensun (see edit history)
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...