I can't understand how can I display all tags in my homepage?

There's a workable solution to display a product's tags in a product page with this code:

// instantiate the tags class for products
$_tags = new Mage_Tag_Block_Product_List();

<!-- ProductTags: -->
<ul class="product-tags">
<?php foreach($_tags->getTags() as $tag):?>
    <li><a href="<?=$tag->getTaggedProductsUrl()?>"><?=$tag->getName()?></a></li>
<?php endforeach;?>

But it doesn't work in home page.

I get error

Fatal error: Call to a member function getItems() on a non-object in app/code/core/Mage/Tag/Block/Product/List.php on line 45

What should I do?

4 Answers 4


to get programmatically popular tag use this code

    $tagmodel = Mage::getModel('tag/tag');
    $collection = $tagmodel->getResourceCollection()

foreach($collection as $tag)
                                //code here
  • hello! You write "to get popular tag", but I get all the tags with your code, not only popular. Anyway seems like this is what I need. Thank you very much May 7, 2015 at 5:31

Add this to the Content section of your hopepage:

{{block type="tag/all" name="tags_all" template="tag/popular.phtml"}}
  • Hi, thanks for your answer, but I need to get all tags, not only popular. May 7, 2015 at 5:28
  • the block tag/all will give you all tags. The block uses the popular template but it should display all the tags.
    – Marius
    May 7, 2015 at 6:17


$tag_model= Mage::getModel('tag/tag');
          $tag_collection= $tag_model->getResourceCollection()
                    ->setFlag('relation', true)


       foreach ($mytags as $tag) {
               echo  $tag->getTaggedProductsUrl();
               echo $tag->getName();

  • Hi, thank you for the answer, but it doesn't work. I get error: Fatal error: Call to a member function getResourceCollection() on a non-object in app/design/frontend/rwd/default/template/page/html/header.phtml on line 352 May 7, 2015 at 5:27

I am giving this answer because the other answers are not working for me. I archived in the following way:

<?php $tagblockobj = Mage::getBlockSingleton('tag/all');?>
 <?php if( sizeof($tagblockobj ->getTags()) > 0 ): ?>
   <?php foreach($tagblockobj ->getTags() as $tag):?>
     <a href="<?php echo $tag->getTaggedProductsUrl()?>" class="tags-b"><?php echo $tag->getName()?></a>
   <?php endforeach;?>  
 <?php else: ?>
      <p class="note-msg"><?php echo $this->__('There are no tags available.') ?></p>
 <?php endif; ?>  

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.