I have a custom module with a block which shows a form inside the product detail page. I need to retrieve the product ID for the currently viewed product inside this block. Everything else is working.
Other answers suggested trying:
$this->getProduct()->getId(); // or
Mage::registry('current_product')->getId();
The former returned an error. Using this one inside the product detail template is working fine. I understand that's because getProduct() is not a method for the block.
The latter is always returning null.
If anyone could help me, that would be great.
Thanks in advance.
EDIT: The custom block layout.xml
<layout version="0.1.0">
<catalog_product_view>
<reference name="content">
<reference name="product.info">
<block
type="s148_interestnotification/form"
name="interest_notification"
before="-"
template="s148_interestnotification/index.phtml"
></block>
</reference>
</reference>
</catalog_product_view>
</layout>