Get product id and product type in magento?

I am creating magento store. I am beginner in magento. I want to get product id and product input type in my phtml file is this possible? please guide me..

I am trying to this way to get product type. but its not working for me

$product=Mage::getModel('catalog/product')->load($product_id);
$productType=$product->getTypeID(); 

Please guide me...

Answers


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();

Also for product type i think

$product = Mage::getModel('catalog/product')->load($product_id); 

$productType = $product->getTypeId();

Need Your Help

Create a multilingual website

javascript android html multilingual

I am an experienced Android developer and in my apps I am used to providing multiple string.xml resource files for different languages.

Nodemailer HTML not working with sendgrid

node.js sendgrid

I am using sendgrid and nodemailer trying to send an HTML email.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.