Guest User

Untitled

a guest
Jul 16th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. protected $_imageBuilder;
  2.  
  3. public function __construct(
  4. ........
  5. MagentoCatalogBlockProductImageBuilder $_imageBuilder
  6. ........
  7. ){
  8. ........
  9. $this->_imageBuilder=$_imageBuilder;
  10. ........
  11. }
  12.  
  13. public function getImage($product, $imageId, $attributes = [])
  14. {
  15. return $this->_imageBuilder->setProduct($product)
  16. ->setImageId($imageId)
  17. ->setAttributes($attributes)
  18. ->create();
  19. }
  20.  
  21. $imageType = 'product_base_image'; //For getting the base image
  22. $imageType = 'product_small_image'; //For getting the small image
  23. $imageType = 'product_thumbnail_image'; //For getting the thumbnail image
  24.  
  25. <?php
  26. $imageType = 'product_thumbnail_image'; //for thumbnail image
  27. $image = $block->getImage($_item, $imageType);
  28. ?>
  29.  
  30. <img src = "<?php echo $image->getImageUrl(); ?>" />
Add Comment
Please, Sign In to add comment