5 Quick Magento Tips You Wish You Knew Earlier

Customize a Magento Store.

If you are looking to customize your Magento store or theme, a majority of times you ought to do very specific tasks. I am listing few of them below. I hope you will love this series and will find out most common solutions to most common Magento tasks.

How to display category title only on sub category page in Magento Template?

To display category title only on sub category page in Magento template go to app/design/frontend/default/Your_Theme/template/catalog/category/view.phtml and find the following line of code

1
<h1 class="page-title1"><?php echo $_helper->categoryAttribute($_category, $_category->getName(), 'name') ?></h1>

simply replace the above line with the following piece of code

1
2
3
4
5
<?php if($_category->getLevel() > 2): //current category is not a parent-category ?>
<div class="category-title"><?php echo $_helper->categoryAttribute($_category, $_category->getName(), 'name') ?></div>
<?php else: //this is a parent category page ?>
//do nothing
<?php endif; ?>
 

How to show 4 products instead of 3 products in a row on Listing Page in a Magento Theme?

To show 4 products instead of 3 on listing page in Magento Theme you need to edit app/design/frontend/default/Your_Theme/template/catalog/product/list.phtml file and add the following line

1
$this->setData('column_count',4);

after this piece of code

1
2
3
4
<?php
 $_productCollection=$this->getLoadedProductCollection();
 $_helper = $this->helper('catalog/output');
?>

Eventually it should look something like this

1
2
3
4
5
<?php
    $_productCollection=$this->getLoadedProductCollection();
    $_helper = $this->helper('catalog/output');
    $this->setData('column_count',4);
?>
 

How to show currency selector in right sidebar in a Magento template?

To show currency selector in right sidebar you need to edit app/design/frontend/default/Your_Theme/layout/directory.xml. Just edit in catalog_category_default, change the reference name from left to right like this

1
2
3
4
5
  <catalog_category_default>
        <reference name="right">
            <block type="directory/currency" name="currency" before="catalog.leftnav" template="directory/currency.phtml"/>
        </reference>
  </catalog_category_default>
 

How to check if current page is homepage in Magento Template?

Using the following code you can check if current page is homepage or not in Magento template.

1
2
3
4
5
6
7
8
if($this->getIsHomePage())
{
    echo "You are on Homepage";
}
else
{
    echo "You are not on Homepage";
}
 

How to retrieve the base Url path in Magento?

This is extremely easy just call this to get the Magento Base URL

1
<?php echo Mage::getBaseUrl(); ?>

Here are additional 10 Magento Customization Tips for you. We would love to hear your questions, comment on these quick tips. Please leave us a comment and let us know.

  • http://www.magentodevelopments.com/magento-development.php magento development

    Magento really is a awesome program, but sometimes it needs a bit of considering to discover a easy function, and these are the 8 most typical issues.
    •I set up Groups but they are not displaying in the front end
    •I create some changes in XML/PHTML information but the changes do not indicate on frontend
    •Sort by Name error
    •Rating desk in the Evaluation website does not display up
    •Terms and Circumstances does not appear in OPC page
    •Breadcrumb is not displaying up in the CMS pages
    •Admin kept tossing me out and ask me to re-log in
    •I do not want my customer re-direct to Assess out website once a item is engaged to cart

  • http://www.kizi10.info/ Kizi 10

    I think that your perspective is deep, its just well thought out and really fantastic to see someone who knows how to put these thoughts down so well.

  • http://www.yepi2.co/ yepi

    wow! articles very great

  • Pingback: 5 Quick Magento Tips You Wish You Knew Earlier

  • Pingback: 10 Magento Customization Tips You Wish You Knew Earlier

  • http://www.magikcommerce.com/ Ashish Nayyar

    These are nice ideas and real pain points. Good points for us to write on.

    Thanks.