Sunday, April 11, 2010

Magento Pagination

Hello People

I am posting the way i did pagination in the My Wishlist Table .I used that way to paginate few other modules(self-built).

This is for1.4.0.1 I don't know about rest fo the version.

1.
code/core/Mage/Wishlist/Block/Customer/Wishlist.php

comment out the _prepareLayout function and add

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;
}

Add One more method in the same file wishlist.php
public function getPagerHtml()
{
return $this->getChildHtml('pager');
}

2 Open /app/design/frontend/base/default/template/wishlist/view.phtml
and add
getPagerHtml(); ?>

above
and below


That's it.

If this is usefull to you don't forget to post the comment.

7 comments:

  1. It doesn't work?? I am using magento 1.4.2 version. It gives me an error saying that getPagerHtml() is an undefined function!

    ReplyDelete
  2. Oh okay..it works. It was a silly mistake. Thanks a lot for the code :)

    ReplyDelete
  3. class Aarna_Designsubmit_Block_Designsubmit extends Mage_Core_Block_Template
    {

    protected function _prepareLayout()
    {
    parent::_prepareLayout();
    $pager = $this->getLayout()
    ->createBlock('page/html_pager', 'wishlist.customer.pager')
    ->setCollection($collection = Mage::getModel('customer/customer')
    ->getCollection()->addAttributeToSelect('*')->addFieldToFilter('group_id',4));
    $this->setChild('pager', $pager);

    return $this;
    }
    public function getPagerHtml()
    {
    return $this->getChildHtml('pager');
    }
    public function getDesignsubmit()
    {
    if (!$this->hasData('designsubmit')) {
    $this->setData('designsubmit', Mage::registry('designsubmit'));
    }
    return $this->getData('designsubmit');

    }


    public function getAvatar( $customer_id )
    {
    $cpBlock = $this->getLayout()->getBlockSingleton('designsubmit/form_edit');

    return $cpBlock->getAvatar( $customer_id );

    }

    ReplyDelete
  4. hello


    i have added pagging in my custom module
    but it is not working



    please help

    ReplyDelete
  5. pagination is not working for my wishlist page..
    plz help me..

    ReplyDelete
  6. Great blog. All posts have something to learn. Your work is very good and i appreciate you and hoping for some more informative posts.keep writing
    magento development company in bangalore 

    ReplyDelete