4

For grouped products, I would like to see the picture of the by-products.

I tried several things but without success:

in files : Magento_GroupedProduct\templates\product\view\type In the loop of associated product, i wrote this code :

$productImage = $block->getImage($_item, 'product_base_image');


<a href="<?php /* @escapeNotVerified */ echo $_product->getProductUrl() ?>" class="product photo product-item-photo" tabindex="-1">
     <?php echo $productImage->toHtml(); ?>
</a>

but it does not work!! Would anyone have an idea. Thanks

  • Did you get the solution? – 3CE Oct 30 '17 at 14:05
0

This is what I have done which might point you in the right direction:

1) It took me forever to get the right path to extend the template from vendor\magento\module-grouped-product\view\frontend\templates\product\view\type\grouped.phtml to my theme directory app\design\frontend\Vendorname\Themename\Magento_GroupedProduct\templates\product\view\type\grouped.html

2) I added the line <?php $productImage = $block->getImage($_item, $image); echo $productImage->toHtml(); ?>

3) the trick now is to figure out how to define what goes in $image - i have created my own definition in my theme app\design\frontend\Vendorname\Themename\etc\view.xml

<?xml version="1.0"?>
<view xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/view.xsd">
<media>
<images module="Magento_Catalog">
        <image id="grouped_list_product_thumbnail" type="thumbnail">
            <width>75</width>
            <height>90</height>
        </image>
 </images>            
</media>
</view>

So for me, $image = "grouped_list_product_thumbnail";

This is working for me although it is showing the placeholder and not the thumbnail - it seems my test migration did not copy the thumbnail linkage properly

This might help you solve yours though :)

| improve this answer | |
  • Hi! There. Images module name would be "Magento_Catalog"? not "Magento_GroupedProduct"? Thank you – 3CE Oct 30 '17 at 14:19
  • yes, grouped products are just a part of Catalog, they don't have a separate module (unlike Bundles which have a module on top) – iphigenie Nov 2 '17 at 11:40

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.