RSS

Tag Archives: how to add view all option in magento

How to add “View All” button in Magento’s pagination

Hi, Here is the solution of How to add view all option in magento pagination…

First of all, we need to trace the “app/design/frontend/your_package/theme/template/page/html/pager.phtml” file in our working template directory. When you do, all that needs to be added is the following code somewhere to fit your needs:

1
2
3
4
<a href="<?php echo $this->getLimitUrl('all')?>" title="< ?php echo $this->__('View All Products') ?>">
< ?php echo $this->__('View All') ?>
</a>

Now we’ve added our link to pagination. And only thing important here is the following segment of code:

1
$this->getLimitUrl('all')

This small segment of code generates our link with “limit” parameter set to “all”. Now when we click on it, it will give us a full category listing. The problem with that is that our value of “limit” set to “all” becomes stored permanently (for as long the session lasts). So we need to write just a couple lines of code more to fix it. Now  in “app/core/code/Mage/Catalog/Block/Product/List/Toolbar.php”  file, find the _construct() method. By default last line of that method is:

1
$this->setTemplate('catalog/product/list/toolbar.phtml');

which sets our (edited) template to this model. Just after that line, add the following code:

1
2
3
//ADDED FOR "VIEW ALL" PAGINATION BUTTON
$defaultLimit = $this->getDefaultPerPageValue();
Mage::getSingleton('catalog/session')->setData("limit_page",$defaultLimit);

So, this is it. I hope it will be helpful for someone.

 
3 Comments

Posted by on Jan 9, 2012 in Magento

 

Tags: , , ,