Magento Adds Pager Toolbar to Wish List

Can I use the catalog collection pager for a wish list, and if so, how can I implement this in my wish list?

+5
source share
2 answers

danny (OP) already answered the question himself.

Quote:


Ok, I found a solution here , but I will also post it here for better code extraction: Create a new module and rewrite the wish list 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');
    }  
}

<?php echo $this->getPagerHtml(); ?> / view.phtml, : /// /_theme/template/wishlist/view.phtml. .


. , . , , . " " ( ).

+5

. ( ) : app\code\local\Mage\Wishlist\Block\Customer\Wishlist.php.
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');
}

}

/app/design/frontend/base/default/template/wishlist/view.phtml

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

div formkey view.phtml :

Magento ver. 1.9.0.1

0

All Articles