Jump to content

[SOLVED] Paginate products count based on category id


yaniv14

Recommended Posts

Hi,

 

I am looking for an idea on how to achieve products page pagination in category page based on categories and not by Configuration::products_per_page.

 

I have different template layouts for different categories and I need to split them to different count.

 

Category 1 = 5 per page.

Category 2 = 12 per page.

Ect.....

 

Any help will be appreciated.

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

Hi, you need to override the controllers/front/CategoryController.php file

 

In the  assignProductList functiion, you need to change

$this->cat_products = $this->category->getProducts($this->context->language->id, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay);

by something like that:

switch ($this->category->id) {

case 1:
$nb_products = 5;
break;

case 2:
$nb_products = 10;
break;

.......

default:
$nb_products = (int)$this->n;


}

$this->cat_products = $this->category->getProducts($this->context->language->id, (int)$this->p, (int)$nb_products, $this->orderBy, $this->orderWay);
Edited by fred-vinapresta (see edit history)
Link to comment
Share on other sites

Hi,

 

I am getting the desire products count per page based on the category id with your suggestion but I am not getting the actual pagination functionality.

 

Do I need to override pagination as well or am I am missing something in the template?

 

Thanks

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...