0

I'd like to add the category title to the product view page in Magento. I have the following code that currently pulls the category banner to the product view page:

<?php
    if(Mage::registry('current_category')):
        $_category=Mage::registry('current_category');
        $_helper    = Mage::helper('catalog/output');
        $_imgHtml   = '';
        if ($_imgUrl = $_category->getImageUrl()) {
            $_imgHtml = '<p class="category-image"><img src="'.$_imgUrl.'"     alt="'.$this->escapeHtml($_category->getName()).'" title="'.$this->escapeHtml($_category->getName()).'" /></p>';
            $_imgHtml = $_helper->categoryAttribute($_category, $_imgHtml, 'image');
        }
?>
    <?php if($_imgUrl): ?>
        <?php echo $_imgHtml ?>
    <?php endif; ?>

<?php endif; ?>

Can I adapt the above so the category title is also displayed?

  • you want to disable category title in listing page right – Magento 2 Oct 5 '15 at 20:13
  • No, I'd like to add the category title to the product view page. – YorkieMagento Oct 5 '15 at 20:15
  • can you plz show me that page – Magento 2 Oct 5 '15 at 20:17
5

Try:

echo $_category->getName();

That should do it!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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