Q:

how it works pagination in prestashop?

I have done some modification and now need to build my own pagination.
So i know prestashop have his own so how can i use them?
I was trying to use in classes/controller/FrontController.php
Use function: 
public function pagination($nbProducts = 10)
        {....

But can't understand well where and how is formed a pagination itself... i think my php knowledgment is low so i need some help if somebody get understand how is pagination of Prestashop works.

A:

Front Controller assign products and the number of products in smarty variables for the page you want to see.
Here the example with BestSales Page in BestSalesController :
$nbProducts = (int)ProductSale::getNbSales();
$bestSales = ProductSale::getBestSales($this->context->language->id, $this->p - 1, $this->n, $this->orderBy, $this->orderWay);
....
// then assign it to smarty
$this->context->smarty->assign(array(
     'nbProducts' => $nbProducts,
     'products' => $bestSales
));

There is nothing special or custom things you can do in Front Controller.
If you want to make a custom pagination, take a look at the blocklayered module.
For example, in modules/blocklayered/blocklayered.php at ajaxCall() function, you can specify custom choices for 'the number of products by page' by editing this line :
$nArray = (int)Configuration::get('PS_PRODUCTS_PER_PAGE') != 10 ? array((int)Configuration::get('PS_PRODUCTS_PER_PAGE'), 10, 20, 50) : array(10, 20, 50);

This line display 10, 20, 50 and default number of products per page specified in Back-Office/Preferences/Products but you can change it as your wish, example :
$nArray = array(10, 20, 30, 40, 50, 60);

If you want to make customizations, you have to made them in this module, but it wouldn't be simple (the file is hitting 4200 lines, so good luck !).

