Monthly Archives: May 2012

Magento Add Custom links to Top menu

Sometime we don’t require to show categry in the top navigation but we require to show our customlinks at the top menu
for example we are taking all footer links to be shown in the top menu where category is showingHow to add footer page links into the header i.e top menuSo first things first login to you admin Backend

1) go to cms and then to Static Blocks >> Add new Block

Title Top Navigation Links

Identifier top_nav_links

Then add this code

<ul id="nav">
<li><a href="{{store url=""}}">Link1</a></li>
<li><a href="{{store url=""}}link1">Link2</a></li>
<li><a href="{{store url=""}}link3">Link3</a></li>
<li><a href="{{store url=""}}link4">Link4</a></li>
<li><a href="{{store url=""}}link5">Link5</a></li>

you will also need to create pages to reflect CMS BLOCK links above

go to cms and then to MANAGE PAGES >> ADD NEW PAGE

2)Now go to apps/design/frontend/your_interface/your_theme/layout/page.xml

after   <block type=”core/text_list” name=”” as=”topMenu”/>

add this line

<block type="page/html_nav" name="nav" as="nav" template="page/html/nav.phtml">
                <block type="cms/block" name="top_nav_links">
                    <action method="setBlockId"><block_id>top_nav_links</block_id></action>

3) Now go to apps/design/frontend/your_interface/your_theme/template/page/html and create one file called


<?php $this->getChildHtml()?> 
<?php if($this->hasSeoLinks()>0):?>
<ul id="nav">
<!--edit this out as these links not needed-->
   <?php foreach($this->getSeoLink() as $item):?>
<li><a href="<?php $item['url'];?>"><?php $item['title'];?></a></li>
<?php endforeach;?>
<!--edit finish-->
<script type="text/javascript">decorateList('footer:seo-links')</script>
<?php endif;?>     

4) Now create one file in local apps/code/core/Mage/Page/Block/Html

and name as Nav.php

and add the following code


class Mage_Page_Block_Html_Nav extends Mage_Core_Block_Template


    protected $_seolinks; 
    protected function _prepareLayout()
    public function setCopyright($copyright)
        $this->_copyright = $copyright;
        return $this;
  public function getCopyright()
        if (!$this->_copyright) {
            $this->_copyright = $this->getDesignConfig('page/nav/copyright');
        return $this->_copyright;
    public function getSeoLink()
        return $this->_seolinks; 
    public function setSeoLink(array $varName)
    public function addSeoLink(array $varName)

    public function hasSeoLinks()
        return count($this->_seolinks);
    public function initSeoLink()

            $seolink['title']=$this->__('Site Map');




            $seolink['title']=$this->__('Search Terms');



5)Now go to in your template/page/html/header.phtml

just comment the line <?php echo getchildhtml(‘topmenu’)?>

and add the new line <?php echo getchildhtml(‘nav’)?>

6) Now last part i.e css

#nav { padding:0 50px; font-size:1.1em; z-index:999;  margin-left:200px;}

that’s it now your custom links will be shown in top menu whereas categroy will not come as we have commented the top menu

Google API Calendar Service with Magento

Google Calendar allows client applications to view and update calendar events in the form of Google Data API feeds. Your client application can use the Google Calendar Data API to create new events, edit or delete existing events, and query for events that match particular criteria.

As Magento is using Zend library so Easily integrated with Magento with some customization

Just Amazing thing from Google which will help to integrate the calendar service from website to internal Google calendar with Zend Library

Reference Links

Hope this will be helpful

Magneto Adding New Layout

Custom Module will help to make the New layout if we don’t want to use the Magento default layout

We can add a new page layout in Magento, create a custom layout or create a new theme layout then here are the steps need to follow

create a module. Create file: app/etc/modules/Mage_Page.xml


Then copy this whole folder: app/code/core/Mage/Page/etc/config.xml  to app/code/local/Mage/etc/config.xml







Now all you have to do is make a template for this page. Navigate to your theme directory: app/design/frontend/YOUR_THEME/YOUR_THEME/template/page/ and create a new template called home.phtml.
same as u can copy 2column-left.phtml or any
his will enable a custom layout option for CMS pages once you’re finished

Magento Best seller and Top seller

To show bestseller at Top seller at home that best products should come on home page.For that follow the following steps
Create a Bestseller.php file and put it here :



class Mage_Catalog_Block_Product_Bestseller extends Mage_Catalog_Block_Product_Abstract{
    public function __construct(){
        $storeId = Mage::app()->getStore()->getId();
        $products = Mage::getResourceModel('reports/product_collection')
            ->addAttributeToSelect(array('name', 'price', 'small_image'))
            ->setOrder('ordered_qty', 'desc'); // most best sellers on top


Create bestseller.phtml file and put it here :



<?php if (($_products = $this->getProductCollection()) && $_products->getSize()): ?>
<?php $i=0; foreach ($_products->getItems() as $_product): ?>
    <?php if ($i>5): continue; endif; ?>
            <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>">
                 <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(65,65); ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>"/>
            <?php echo $_product->getDescription(); //also getShortDescription ?>
            <p><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>)"><?php echo $_product->getName() ?></a></p>
            <?php //echo $this->helper('review/product')->getSummaryHtml($_product, 'short') //product review link ?>
            <?php echo $this->getReviewsSummaryHtml($_product, false, true)?>
            <?php //echo $this->helper('catalog/product')->getPriceHtml($_product) ?>
            <?php echo $this->getPriceHtml($_product) ?>
            <?php echo $_product->getProductId(); ?>
            <?php if($_product->getevent_date()) {echo $_product->getevent_date();} ?>
<?php $i++; endforeach; ?>
<?php for($i;$i%5!=0;$i++): ?>
    <?php endfor ?>
<?php endif; ?>

now put this line where you want to view best selling products..

you can use through block or through XML also

{{block type=”catalog/product_bestseller” template=”catalog/product/bestseller.phtml”}}


<block type=”catalog/product_bestseller” name=”bestseller” template=”catalog/product/bestseller.phtml”>


Hope this will help you!

Magneto Get Router.Controller,Module,Action Name

Generally we get confused while checking the controller name .so require to known name for the controller,router,module,action.Below are the following methods which will help to get the controllers ,action ..etc as per the need

$this->getRequest() can be used

get Controller name

get Action name, i.e. the function inside the controller

get Router name

get module name

IN CLASS FILES menas php files
$this might not work.In this case, you need to use Mage::app().

get Controller name

get Action name, i.e. the function inside the controller

get Router name

get module name

This functions (getControllerName, getActionName, getRouteName, getModuleName)
are present in the class Mage_Core_Model_Url.

Hope this will help You….