enloz
enloz

Reputation: 5824

Get product ID in Admin Panel

How to get current product ID in Admin Panel / Catalog / Manage Products / Tab ?

enter image description here

I have a custom product tab and no idea how to get current product ID.

In frontend I would do something like this:

<?php $_product = $this->getProduct(); ?>
<?php echo $_product->getId() ?>

Upvotes: 4

Views: 6171

Answers (3)

clockworkgeek
clockworkgeek

Reputation: 37700

If you look at Mage_Adminhtml_Catalog_ProductController you will see the product in question twice, so either of these will work:

$product = Mage::registry('product');
echo $product->getId();

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

Upvotes: 9

$this->getRequest()->getParam(’id’);

Upvotes: 0

Magento Guy
Magento Guy

Reputation: 2493

You can find the product ID in the URL:

http://yourmagento.install.com/index.php/admin/catalog_product/edit/id/[here_it_is]/key/35db6b1fdadbcf2867d06150blahblahblahblahblahc19697f1a28cd141051/

Failing that, I'll have a look at what template file you'll need to edit.

EDIT:

app/design/adminhtml/default/default/template/catalog/product/edit.phtml

After this line:

<h3 class="icon-head head-products"><?php echo $this->getHeader() ?></h3>

Put this:

<?php if($this->getProductId()){ echo $this->getProductId(); } ?>

Upvotes: 1

Related Questions