Magento 2 Overrides – How to Override HTML Template

magento2magento2-dev-betamoduleoverrides

I create new Block Xyaddons\Productzoom\Block\Product\View\Gallery override Block \Magento\Catalog\Block\Product\View\Gallery.
I want set template image.phtml in Xyaddons_Productzoom::product/image.phtml override template product/view/base-image.phtml in core.
I try create function in block new Block. But i not success. so any help me? thank so much!

public function beforeToHtml(\Magento\Catalog\Block\Product\Gallery $originalBlock) {       
        $originalBlock->setTemplate('Xyaddons_Productzoom::produtc/image.phtml');
    }

Best Answer

<referenceBlock name="catalog_product_gallery">
    <action method="setTemplate">
        <argument name="template" xsi:type="string">Xyaddons_Productzoom::produtc/image.phtml</argument>
    </action>
</referenceBlock>
Related Topic