Created
December 29, 2018 12:25
-
-
Save yogeshdubey2006/5b308896155a1907a21d5d2db9e5cce9 to your computer and use it in GitHub Desktop.
Magento 2 get product id to my custom module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); | |
$product = $objectManager->get('Magento\Framework\Registry')->registry('current_product'); //get current product | |
echo $product->getId(); | |
echo $product->getName(); | |
?> | |
<?php | |
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); | |
$productid = $this->getRequest()->getParam('id'); | |
$product = $objectManager->create('Magento\Catalog\Model\Product')->load($productid); | |
echo $product; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment