cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with catalog_product_view.xml and product.info.media.image block (replacing .phtml)

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

Problem with catalog_product_view.xml and product.info.media.image block (replacing .phtml)

Hi folks!

For few days I'm trying to replace product.info.media.image .phtml file using my own module without any luck. I just don't understand why it doesn't work at all.

Original catalog_product_view.xml:

		<referenceContainer name="content">
			<block class="Magento\Catalog\Block\Product\View" name="product.detail.info" as="product_detail_info" template="product/view/detail_layout.phtml" after="-" >
					<block class="Magento\Framework\View\Element\Template" name="product.detail.sharethis" after="-" template="MGS_Mpanel::sharethis/sharethis.phtml"/>
					<block class="Magento\Catalog\Block\Product\View\Gallery" name="product.info.media.image" template="Magento_Catalog::product/view/gallery.phtml"/>
			</block>
		</referenceContainer>

Block product.info.media.image is nested but it shouldn't be a problem, right?

I can point product.detail.info and replace it but I want to change only  product.info.media.image 

 

My .xml

<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
 <body>
        <referenceBlock name="product.info.media.image">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">MY_module::catalog/product/view/test.phtml</argument>
            </action>
        </referenceBlock>
    </body>
</page>

name is correct because I can remove this block using

 <referenceBlock name="product.info.media.image" remove="true">

Any other referenceBlock name works normally - just not this one. I tried even using Class with di.xml - same. Nothing.

 

I'm using Magento 2.2.7

Appreciate any help....