I created placed custom html in Magento_Catalog>template>product>view>details.phtml file in Magento_Catalog module and added below code to get current product ID and name

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product = $objectManager->get('Magento\Framework\Registry')->registry('current_product');
$_product_id = $product->getId();
$_product_name = $product->getName();

What are the other functions to get product details like Price, Images, Short & Long description, etc...

Please sugest me the list of functions i can use to get product details.

Please help me if you know answer to this Question also

  • 1
    You can take reference from this file for get product details magento/vendor/magento/module-catalog/view/frontend/templates/product/list.phtml Jun 29, 2019 at 17:17

3 Answers 3


You can get price,sku,description by following code

$_product_price = $product->getPrice();
$_product_image= $product->getImage();
$_product_sku = $product->getSku();

updated solution get category ids and images by following code

protected $_productRepositoryFactory;

public function __construct(
        \Magento\Catalog\Api\ProductRepositoryInterfaceFactory $productRepositoryFactory
) {

    $this->_productRepositoryFactory = $productRepositoryFactory;

In function

 $_items = $order->getAllItems();
foreach($_items as $_item)

$product = $this->_productRepositoryFactory->create()->getById($item->getProductId());
  • 1
    Did you try this? Jul 2, 2019 at 6:31
  • I'll try that. how can we get images of the same product? getGallery??? and category also? getCategory?
    – rakcode
    Jul 3, 2019 at 10:32
  • Thanks. Can you please check my another question. no one replied to me on that one! :(
    – rakcode
    Jul 3, 2019 at 11:15
  • 1
    Did you check updated answer? Jul 3, 2019 at 11:16
  • Yes its working fine for me. Thanks.
    – rakcode
    Jul 3, 2019 at 12:56

You current_product is the object of following class:




Now you open this class and search your actual method.


Following code will list you a functions list to get product data according to your code.

echo "<pre>";

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.