Cleyton
Cleyton

Reputation: 2468

How to get product ID in magento inside head section?

Id like to make this work inside themeName/template/page/html/head.phtml

<?php echo $_product->getId()

I'm trying to add a script in head section and it requires productID, but it only works inside catalog/product.

Is there a way to make it work in head section?

Upvotes: 0

Views: 2457

Answers (1)

MagePal Extensions
MagePal Extensions

Reputation: 17656

Try

if($_product = Mage::registry('current_product')){
   echo $_product->getId()
}

See Magento - Passing data between a controller and a block

Upvotes: 3

Related Questions