Search code examples
magentomagento2magento-2.0

How to get product information from product id in magento2 or magento2.0?


How to get all product details by product id in magento2? I want to display a single product detail with the image on the homepage. Any help would be appreciated.


Solution

  • Try below code. It may help you.

    <?php 
       $productId = 10;
       $objectManager =  \Magento\Framework\App\ObjectManager::getInstance();
       $currentproduct = $objectManager->create('Magento\Catalog\Model\Product')->load($productId);
    ?>