Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected $_imageBuilder;
- public function __construct(
- ........
- MagentoCatalogBlockProductImageBuilder $_imageBuilder
- ........
- ){
- ........
- $this->_imageBuilder=$_imageBuilder;
- ........
- }
- public function getImage($product, $imageId, $attributes = [])
- {
- return $this->_imageBuilder->setProduct($product)
- ->setImageId($imageId)
- ->setAttributes($attributes)
- ->create();
- }
- $imageType = 'product_base_image'; //For getting the base image
- $imageType = 'product_small_image'; //For getting the small image
- $imageType = 'product_thumbnail_image'; //For getting the thumbnail image
- <?php
- $imageType = 'product_thumbnail_image'; //for thumbnail image
- $image = $block->getImage($_item, $imageType);
- ?>
- <img src = "<?php echo $image->getImageUrl(); ?>" />
Add Comment
Please, Sign In to add comment