I want the product image to change on "catalog-category-view" depending on whether the product is 'grouped' or 'simple'.
In Magento_Catalog\templates\product\list.phtml the product image is called by
<?php echo $productImage->toHtml(); ?>
which calls image_with_borders.phtml
Here i tried something like that:
<?php $_productCollection = $block->getLoadedProductCollection(); $is_grouped = $_productCollection ->getTypeId() == 'grouped'; if ($is_grouped != 1): echo "yes"; //example else : echo "no"; //example endif; ?>
But i always get:
Fatal error: Uncaught Error: Call to a member function getTypeId() on null
How can i achieve this? I'm using that sort of code in list.phtml to differentiate between grouped and simple products and it'S working.
Specs: Magento Ver.-2.3.4 | PHP 7.2