RSS

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

09 Jan

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: , , ,

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

  1. Vladimir

    Apr 14, 2012 at 6:00 pm

    Hello!
    Excellent work!

     
  2. Abhilash

    Jun 20, 2013 at 4:35 pm

    This worked great. But the paging like 1,2,3 etc has gone when I click ‘View All’ link. The paging(1,2,3 etc) will display if I take link like this http://sitename.com/magent/p=3 or http://sitename.com/magent/p=2 etc.

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: