user2064667
user2064667

Reputation: 124

Product category name on product viewing page

I'm working on a website. Upon clicking the product it shows all the details of it. But my client want me to show parent category of categroy of the product at top, above the image. Please help me about it. I'm a budding developer.

Upvotes: 0

Views: 931

Answers (2)

Hardik
Hardik

Reputation: 1283

Try this may be help someone else.

<?php $_helper = $this->helper('catalog/output');?>
<?php $_category_detail=Mage::registry('current_category');?>
<?php $_category_detail->getName();?>
<?php $_category_detail->getId(); ?>

Upvotes: 1

Oleg Ishenko
Oleg Ishenko

Reputation: 2233

You can get the category data from your product object: $_product->getCategory()->getName();. You will have to edit the template at template/catalog/product/view.phtml. In the template file look for <div class="product-img-box"> and add:

        <div class="product-img-box">
            <h4><?php echo $_product->getCategory()->getName(); ?></h4>
            <?php echo $this->getChildHtml('media') ?>
        </div>

Upvotes: 0

Related Questions