January 21, 2011

Magento Add Home button to horizontal Top Navigation

In this post I will show you how to add a Home button to your Horizontal Top Navigation like on this website www.ruitersport-discounter.nl

Ruitersport-Discounter - Home button
Home button on the left side of the Horizontal Top Navigation Bar














We are going to edit the following file:
\app\design\frontend\default\default\template\catalog\navigation\top.phtml
 Within the <div class="nav-container"><ul id="nav">, but above the <?php echo $_menu ?>, paste the following code snippet:

<?php $_anyActive = false; foreach ($this->getStoreCategories() as $_category) { $_anyActive = $_anyActive || $this->isCategoryActive($_category); } ?>
<li class="<?php echo !$_anyActive ? 'active' : '' ?>"><a href="<?php echo $this->getUrl('')?>"><?php echo $this->__('Home') ?></a></li>

January 18, 2011

Magento hide Callouts from every page in catalog.xml

To hide the Callout blocks from every page on your website, we are going to edit the following file:
\app\design\frontend\default\default\layout\catalog.xml
In this file the behaviour of various default blocks are handled.
To hide the Callouts we have to comment or delete the whole code block:
<block type="core/template"> ... </block>
Now you are all set. You may have to Flush Cache from Magento Admin.

Magento hide Recently Compared Products Block and Recently Viewed Products Block

To hide the Recently Viewed Products Block and Recently Compared Products Block on ALL pages on the website, we are going to edit the file:
\app\design\frontend\default\default\layout\reports.xml
Comment out the two block types within the <reference> tag like:

<!-- <block type="reports/product_viewed" before="right.permanent.callout" name="right.reports.product.viewed" template="reports/product_viewed.phtml" /> -->
<!-- <block type="reports/product_compared" before="right.permanent.callout" name="right.reports.product.compared" template="reports/product_compared.phtml" /> -->

Now you are all set. You may have to Flush Cache from Magento Admin.

Magento show custom static block only on homepage

In this post I will show how to create a custom static block in Magento and show the contents from this block on the Homepage. So in short, show a Static Block in a CMS Page.

The easy part is that we can do this in Magento Admin only. This is an example taken from one of my e-commerce websites www.paardcare.nl :

Content from the Static Block is highlighted. 

















  1. First, create a Static Block: CMS > Static Block > Create new Static Block. The Block identifier is important as we are going to call this block by this ID. You can put anything in the contents from this Block. We've created a <div> container with a <a href><img> construction.
  2. Next, edit the Homepage in CMS > Pages > [Homepage] > Custom Design > Layout update XML. Within the <reference name="left"> ... </reference> tag paste the following syntax/snippet:

    <block type="cms/block" name="[RANDOMNAME]" before="-">
        <action method="setBlockId"><block_id>[YOUR_BLOCK_IDENTIFIER]</block_id></action>
    </block>
That is all to it. Feel free to +1 this post to spread the word or click on a random banner on this site.

January 13, 2011

Magento add sku or product number to shopping cart item in the checkout page

It is not difficult in Magento to add a sku, product number or any other product attribute to the shopping cart item on the checkout page. On our e-commerce website, http://www.paardcare.nl , our wish was to add the Sku number to the shopping cart. This can be done using:

$this->getChildProduct()->getAttribute();













The following file must be edited:
\app\design\frontend\default\default\template\checkout\cart\item\default.phtml

Around Line 36 place the this block:
<span style="color: #AAAAAA; font-weight: normal; font-style: italic;">- Art.
<?php
    if(is_object($this->getChildProduct())): 
        echo $this->getChildProduct()->getSku();
    else: 
        echo $_item->getSku();
    endif; ?>
</span>

This will look like:
Our snipped within the default code

January 8, 2011

Magento remove Paypal logo or other things from static page

A basic Magento template comes with default blocks you probably do not want. For my project at http://www.paardcare.nl (an equestrian horseriding e-commerce website) I had to remove all standard blocks.

To remove the Paypal logo from a static page (hompage) no programming is required. Simply login the admin panel and browse to:

CMS > Static Pages > Home Page > Design

In the layout update XML just paste within <reference> tags:
<reference name="left">
    <remove name="paypal.partner.right.logo"/>
</reference>

This trick works for the following as well:

  • Popular Tags block
  • Sidebar Cart block
  • Sidebar Compare block
  • Viewed Products block

Remove the blocks by putting them within the <reference> tag like:

<reference name="left">
    <remove name="paypal.partner.right.logo"/>
    <remove name="tags_popular"></remove>
    <remove name="cart_sidebar"></remove>
    <remove name="catalog.compare.sidebar"></remove>
    <remove name="right.reports.product.viewed"></remove>
    <remove name="sale.reorder.sidebar"></remove>
</reference>