Wednesday, February 19, 2014

Magento: Add breadcrumbs in custom module

There are following way to add breadcrumbs
1. From layout files
Suppose the layout file for you module is present in design/frontend/default/default/layout/custommodule.xml.

Now, open the layout xml file of your module. You must see the node named default. Write the following code inside the default node or suppose, you have an address page for you module. The test page will have the node named something like YourModule_index_test.

<reference name="breadcrumbs">
            <action method="addCrumb">
                <crumbName>Home</crumbName>
                <crumbInfo><label>Home</label><title>Home</title><link>/</link></crumbInfo>
            </action>
            <action method="addCrumb">
                <crumbName>Test</crumbName>
                <crumbInfo><label>Test</label><title>Test</title></crumbInfo>
            </action>
</reference>


Tuesday, February 18, 2014

Magento : Add pagination to Wishlist


Create a custom module then override a core class 'Mage_Wishlist_Block_Customer_Wishlist'
and add following methods _prepareLayout(), getPagerHtml()
as
<?php
class Bd_Custommodulet_Block_Wishlist_Customer_Wishlist extends Mage_Wishlist_Block_Customer_Wishlist
{
     /**
     * 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(); ?>