View all products link on category page PrestaShop

View all on category page prestashop

In this short tutorial we will show how to add view all products link on every category page. This tutorial is based on PrestaShop version 1.5. View all link will lead to all products from a category.

Please remember that you conduct all changes on your own risk.

First of all you have to modify assignProductList method in CategoryController class. To do so make a new file (if file does not exist) called CategoryContoller.php in override/controllers/front and add folowing lines


class CategoryController extends CategoryControllerCore


Inside class copy method  assignProductList from original file and modify content in following if condition

		if (!$hookExecuted)
			$this->context->smarty->assign('categoryNameComplement', '');

                        $showProducts = Tools::getValue('showProducts');
                        if ($showProducts == 'all') {
                            $this->cat_products = $this->category->getProducts($this->context->language->id, null, null, $this->orderBy, $this->orderWay, false, true, false, 1, true, null, true);
                        } else {
                            $this->nbProducts = $this->category->getProducts(null, null, null, $this->orderBy, $this->orderWay, true);
                            $this->pagination((int)$this->nbProducts); // Pagination must be call after "getProducts"                            
                            $this->cat_products = $this->category->getProducts($this->context->language->id, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay);

When category link is fired in a browser, the 'showProducts' parameter is checked. If value is set to 'all', modified getProducts method from Category model will be called.

Next we will have to override previously mentioned model. Make a new file named Category.php (if it does not exist) in override/classes and modify file


class Category extends CategoryCore

Now copy getProducts method from original file and add one more parameter in function (showAllProducts)

public function getProducts($id_lang, $p, $n, $order_by = null, $order_way = null, $get_total = false, $active = true, $random = false, $random_number_products = 1, $check_access = true, Context $context = null, $showAllProducts = false)

Now find $random === true condition and modify it this way

		if ($random === true)
			$sql .= ' ORDER BY RAND()';
			$sql .= ' LIMIT 0, '.(int)$random_number_products;
			$sql .= ' ORDER BY '.(isset($order_by_prefix) ? $order_by_prefix.'.' : '').'`'.pSQL($order_by).'` '.pSQL($order_way);
                        if (!$showAllProducts) {
                            $sql .= ' LIMIT '.(((int)$p - 1) * (int)$n).','.(int)$n;

Additional code toggles on/off LIMIT in sql query. That allows to show (or not) limited no. of products.

Last thing you have to do is to open pagination.tpl file in your template folder (themes/YOUR_TEMPLATE/pagination.tpl) and add folowing line of code just before the end of last if condition

{if $start!=$stop} 
<a rel="nofollow" href="{$request}?showProducts=all">{l s='View all'}</a>

Rel attribute will prevent search bots from indexing a link. {$request} will display correctly whole url of the category. You may have to change ? To & if your link has already parameters like (/index.php?id_category=3&controller=category).



In order to ensure maximum convenience to users when using the website, this page uses cookie files. Detailed information is available in our Privacy Policy. Click " I agree", so that this information is no longer shown