0

I want to display product tags above tags form for all users on product page and category page also.

2

3 Answers 3

0

Please use below code:

<?php
                $tagmodel = Mage::getModel('tag/tag');
                $collection = $tagmodel->getResourceCollection()
                                            ->addPopularity()
                                            ->load();
                foreach($collection as $tag){ ?>
                     <a href="<?php echo $tag->getTaggedProductsUrl();?>"><?php echo $tag->getName();?></a>
            <?php }  ?>
0
  $model = Mage::getModel('tag/tag');
  $TaGCollection= $model->getResourceCollection()
            ->addPopularity()
            ->addStatusFilter($model->getApprovedStatus())
            ->addProductFilter($ProductId)
            ->setFlag('relation', true)
            ->addStoreFilter(Mage::app()->getStore()->getId())
            ->setActiveFilter()
            ->load();

use below to fetch

$Tags=$TaGCollection->getItems();

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

    }
 endif;
0

Add this code :

<?php $tagCollection = Mage::getModel('tag/tag')->getResourceCollection()
                     ->addPopularity()
                     ->load();
 foreach($tagCollection as $tag): ?>
 <a href="<?php echo $tag->getTaggedProductsUrl();?>"><?php echo $tag->getName();?></a>
        <?php endforeach;  ?>


- in template product category and product view ex: template\catalog\product\view.phtml
pls add this code to call this anywhere that you want

Example: i add above form

 <div class="product-essential">
  <?php $tagCollection = Mage::getModel('tag/tag')->getResourceCollection()
                     ->addPopularity()
                     ->load();
 foreach($tagCollection as $tag): ?>
 <a href="<?php echo $tag->getTaggedProductsUrl();?>"><?php echo $tag->getName();?></a>
        <?php endforeach;  ?>

  <form action="<?php echo $this->getSubmitUrl($_product, array('_secure' => $this->_isSecure())) ?>" method="post" id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
        <?php echo $this->getBlockHtml('formkey') ?>
        <div class="no-display">
            <input type="hidden" name="product" value="<?php echo $_product->getId() ?>" />
            <input type="hidden" name="related_product" id="related-products-field" value="" />
        </div>

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.