I have a phtml file that displays/echo's a block of HTML code that I wish to place onto the product page of my website.

basically, I'd like to add this piece of code to the view.phtml:

echo $this->getChildHtml('product_categories');

The fileself resides in catalog/product/categories.phtml - and needs to access $this->getProduct(); in order to do it's "coding".

I understand that my phtml file needs to reside inside of the skin that I created - and I have done that. How can I setup/tell magento that 'my_data' is a block or phtml file that resides in where I put it, so that it get's executed?

Thank you

2 Answers 2


I would suggest that you could add your block as a child of the block product.info.additional and then you would not have to change any templates as this block will get the html of all it's children.

Normally also the block that you are using on a product page is often of type catalog/product_view. This will allow you to get the current product and use other common functions to do with product view.

  • Thank you. The catalog/product_view was the last piece of the puzzle and solved my problem!
    – Kevin Hill
    Commented Jun 26, 2014 at 20:07

add your phtml file in app/design/frontend/theme/catalog/product folder or app/design/frontend/default/default/catalog/product folder.

Then you have to add the below code <block type="core/template" name="product.mydata" as="media" template="catalog/product/my_data.phtml"/> under the handle tag in layout/catalog.xml

  • when my phtml calls $this->getProduct(); it returns a no object? Any idea how I should fix that?
    – Kevin Hill
    Commented Jun 26, 2014 at 19:51
  • I tried to upvote you both - but it would not let me. :(
    – Kevin Hill
    Commented Jun 26, 2014 at 20:07

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.