Answers for "get product all image in magento1"

2

magento 2 get product image

//todo get product object $product 

$objectManager =\Magento\Framework\App\ObjectManager::getInstance();
$helperImport = $objectManager->get('\Magento\Catalog\Helper\Image');

$imageUrl = $helperImport->init($product, 'product_page_image_small')
                ->setImageFile($product->getSmallImage()) // image,small_image,thumbnail
                ->resize(380)
                ->getUrl();
echo $imageUrl;
Posted by: Guest on November-06-2020
1

magento 2 get product image

use Magento\Framework\App\ObjectManager;
use Magento\Framework\View\Element\Template;
use Magento\Catalog\Model\Product;

class myClass extends Template
{	
	/**
	 * @param \Magento\Catalog\Model\Product $product
	 * @return \Magento\Catalog\Block\Product\Image
	 */
	public function getProductImage(Product $product){
		$objectManager =\Magento\Framework\App\ObjectManager::getInstance();
		/** @var \Magento\Catalog\Block\Product\ImageBuilder $imageBuilder */
		$imageBuilder = $objectManager->create(\Magento\Catalog\Block\Product\ImageBuilder::class);
		return $imageBuilder->create($product, 'category_page_grid');
	}
}

// in phtml use
<?=$block->getProductImage($product)?>
Posted by: Guest on December-10-2020

Code answers related to "get product all image in magento1"

Code answers related to "Objective-C"

Browse Popular Code Answers by Language