Jump to content

[SOLVED] Paginate products count based on category id


yaniv14
 Share

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)

Share this post


Link to post
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)

Share this post


Link to post
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

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More