I want to add images to items in the grouped data table. My code is:

<?php $productImage = $_imagehelper->init($_item, 'product_base_image')
<img src="<?php echo $productImage; ?>">

I add this column next to simple product name in grouped table on file grouped.phtml but instead of base image from simple product i get defalut placeholder image.


you can try this code.

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$_item = $objectManager->create('Magento\Catalog\Model\Product')->load(YOUR_PRODUCT_ID);

$product_image = $this->imagehelper->init($_item,'category_page_list')->constrainOnly(FALSE)->keepAspectRatio(FALSE)->keepFrame(FALSE)->resize(120,90)->getUrl();
  • 1
    Still the same problem. I also tried to take code from cart where simple products has images on the left side but it still doesn't work and i get default magento image – MrFreeSoul666 Mar 17 '17 at 13:01
  • you need load product in $_item before used above code. – Dhiren Vasoya Mar 17 '17 at 13:03
  • I update my answer, you need to do that things. – Dhiren Vasoya Mar 17 '17 at 13:06
  • Sorry but i'm a newbie so in: load(YOUR_PRODUCT_ID); what should i put in ( ) ? – MrFreeSoul666 Mar 17 '17 at 13:16
  • you need try put $_item->getId(); – Dhiren Vasoya Mar 17 '17 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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