Magento get parent category


/ Published in: PHP
Save to your folder(s)

works in produktdetail magento 1.4.2 & 1.5.0.1


Copy this code and paste it in your HTML
  1. <div class="backtocat">
  2. <?php
  3. if ($this->getProduct()->getCategory() != NULL) {
  4. $cat = $this->getProduct()->getCategory();
  5. $parent_cat = $cat->getName();
  6. $cat_url = $cat->getUrl()
  7. ?>
  8.  
  9. <a href="javascript:history.go(-1)" title="<?php echo $parent_cat;?>"><?php echo $this->__('back to category');?> <?php echo $parent_cat;?></a>
  10. <?php } else { ?>
  11.  
  12. <a href="javascript:history.go(-1)" title="back"><?php echo $this->__('Back');?></a>
  13. <?php } ?>
  14.  
  15. </div>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.