I can get tags in a view.phtml file like this:

$_tags = new Mage_Tag_Block_Product_List();

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

It works fine in a single product page. But the code above doesn't work in categories; it returns 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

As I understand the tags class cannot be instantiated.

But how can I display tags list in a category instead of products? When I click on a tag I should get all products with this tag. Also one tag must not be repeated twice.

Any ideas how to solve this issue?

edited: I'll try to give more details...

There's a layered navigation on my home page called "Gifts". This is a simple filter with attributes.

When I choose some attritube(for example "gender - male") and press "Search" I redirect to a category "Gifts" and get result with products which have an attribute gender "male". But on the first step when I get result I need to display NOT products, I need to display their tags.

For example, a product with attribute "male" can contain some tags "creative, relaxation, father, husband" etc... Another product with attribute "male" can contain the same tags as above, but these tags won't be displayed again. So we see only unique tags from all products.

On the second step when we click on tag "creative" we'll get all products with this tag.

Hope this explanation was helpful.

  • 1
    You want to see all tags or just the ones for the products in that specific category?
    – Marius
    Oct 22, 2014 at 6:26
  • please clear the question?
    – Amit Bera
    Oct 22, 2014 at 6:32
  • Hi, guys. I want to see all tags only from a specific category, but tags with the same name must not repeat more than one time. I've added more info in my question. Hope it will help you to understand the meaning Oct 22, 2014 at 8:07

2 Answers 2


Hi you can get tag list of a product using load of tag/tag resource model

Please try this code

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

My code only show approve tag.

Then you can get tags list by loop collection


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

  • ok, i will give you sortly
    – Amit Bera
    Oct 22, 2014 at 8:32
  • hi check now...
    – Amit Bera
    Oct 22, 2014 at 9:25
  • thank you for help. Now I get error: Fatal error: Call to undefined function getItems() on line with a string $Tags=$TaGCollection>getItems(); Oct 22, 2014 at 9:50
  • i will check........ give me 5min
    – Amit Bera
    Oct 22, 2014 at 9:53
  • silly mistake > should be ->
    – Amit Bera
    Oct 22, 2014 at 9:58

In Magento 1.9.2 we had to make a few changes to Amit's answer to get it working:

$id = $_helper->productAttribute($_product, $_product->getId(), 'id');
$model = Mage::getModel('tag/tag'); 
$TaGCollection= $model-getResourceCollection() 
     ->setFlag('relation', true) 

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.