Magento add pager toolbar to wishlist
Asked Answered
F

2

6

Is it possible to use the catalog collection pager for the wishlist, and if so how can I implement this into the wishlist?

Fanechka answered 9/8, 2011 at 9:19 Comment(1)
@denny: +1 for same issue i got.Isom
A
5

danny (OP) already self-answered the question.

Quote:


Ok, i've found the solution here but i'll post it here too for a better code highlighting: Create a new modul and overwrite the wishlist block located in: code/core/Mage/Wishlist/Block/Customer/Wishlist.php and add the following to your Wishlist.php

class Company_Wishlist_Block_Customer_Wishlist extends Mage_Wishlist_Block_Customer_Wishlist
{
    protected function _prepareLayout()
    {
        parent::_prepareLayout();
        $pager = $this->getLayout()
                      ->createBlock('page/html_pager', 'wishlist.customer.pager')
                      ->setCollection($this->getWishlist());
        $this->setChild('pager', $pager);
        $this->getWishlist()->load();
        return $this;
    }
    public function getPagerHtml()
    {
        return $this->getChildHtml('pager');
    }  
}

now add <?php echo $this->getPagerHtml(); ?> to the start and/or end of the view.phtml located in: app/design/frontend/default/your_theme/template/wishlist/view.phtml. that should do the trick.


Note: It's absolutely OK to self-answer your own question. Please just post it as an real answer, but not in a question or comment. Posting as real answer helps to keep the "Unanswered" list more clear (avoids making other people wasting their time).

Agenda answered 9/8, 2011 at 9:19 Comment(1)
@gowri hey gowri, this is working for me in magento 1.5.1.0 w/o problems, what errors you get?Fanechka
R
0

you do not need to create a new module.just create (with folder) in your local : app\code\local\Mage\Wishlist\Block\Customer\Wishlist.php.
and enter the following code on Wishlist.php

<?php class Mage_Wishlist_Block_Customer_Wishlist extends Mage_Wishlist_Block_Abstract {
/**
 * Preparing global layout
 *
 * @return Mage_Wishlist_Block_Customer_Wishlist
 */
protected function _prepareLayout()
{
    parent::_prepareLayout();
    $pager = $this->getLayout()->createBlock('page/html_pager', 'wishlist.customer.pager');
    $pager->setAvailableLimit(array(5=>5,10=>10,20=>20,'all'=>'all'));
    $pager->setCollection($this->getWishlist());
    $this->setChild('pager', $pager);
    $this->getWishlist()->load();
    return $this;
}

/**
 * Pager HTML
 *
 * @return HTML
 */
public function getPagerHtml()
{
    return $this->getChildHtml('pager');
}

}

After that add following code in /app/design/frontend/base/default/template/wishlist/view.phtml

<?php echo $this->getPagerHtml(); ?>

after title div and after formkey in end of view.phtml : image example

tested on Magento ver. 1.9.0.1

Runlet answered 16/6, 2015 at 10:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.