I am grabbing a product object with:
$productId = 9184;
$objectManagerProd = \Magento\Framework \App\ObjectManager::getInstance();
$currentproduct = $objectManagerProd->create('Magento\Catalog\Model\Product')->load($productId);
I have tried to grab the product image with the image helper but it is not working. I have tried getImage() as well. Any body can help? Thanks!
Get product image from Product in PHTML file for Magento 2
$_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$imageHelper = $_objectManager->get('\Magento\Catalog\Helper\Image');
<?php $image_url = $imageHelper->init($product, 'product_thumbnail_image')->setImageFile($product->getFile())->resize($imagewidth, $imageheight)->getUrl(); ?>
try using imageHelper like following :
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$helperImport = $objectManager->get('\Magento\Catalog\Helper\Image');
$imageUrl = $helperImport('Magento\Catalog\Helper\Image')
->init($currentproduct, 'product_page_image_large')
->setImageFile($currentproduct->getFile())
->getUrl();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With