Google+

Pages

Tuesday, May 15, 2012

How to get current product id

Try below code to get currently loaded product id:

$product_id = $this->getProduct()->getId();

When you don’t have access to $this, you can use Magento registry:

$product_id = Mage::registry('current_product')->getId();

Enjoy.. :)

3 comments:

sarvesh kumar said...

Thnks... :D

Its very useful for me !!!

Anonymous said...

$product_id = Mage::registry('current_product')->getId();


above code helpful to me.
Punit.

Mangat Saini said...

Thanks, very useful!!