I want override Block Magento\Catalog\Block\Product\View\Gallery this is code in file di.xml
Edited
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<preference for="Magento\Catalog\Block\Product\View\Gallery" type="Xyaddons\Productzoom\Block\Product\View\Gallery" />
</config>
Code file Gallery.php
namespace Xyaddons\Productzoom\Block\Product\View;
use Magento\Framework\View\Element\Template;
class Gallery extends \Magento\Catalog\Block\Product\View\Gallery
{
protected function _toHtml()
{
$this->setModuleName($this->extractModuleName('Magento\Catalog\Block\Product\View\Gallery'));
return parent::_toHtml();
}
/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
protected $_scopeConfig;
/**
* Template image only
*
* @var string
*/
protected $_templateImage = 'Xyaddons_Productzoom::product/image.phtml';
protected function _prepareLayout()
{
$this->getLayout()->createBlock('Xyaddons\Productzoom\Block\Product\View\Gallery', 'xyaddons.productzoom')->setTemplate('Xyaddons_Productzoom::produtc/image.phtml');}
}
when run code don't running image.phtml and not override Block Magento\Catalog\Block\Product\View\Gallery. What wrong?