I'm trying to override native block Magento\Catalog\Block\Product\View.php, because i want to render my custom(copied) template addtocart.phtml and use my custom methods on this template.
Here is my DI - Wodev\Guestcheck\etc\di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Catalog\Block\Product\View" type="Wodev\Guestcheck\Block\Product\View" />
</config>
Here is my block - Wodev\Guestcheck\Block\Product\View.php
<?php
namespace Wodev\Guestcheck\Block\Product;
use Magento\Catalog\Api\ProductRepositoryInterface;
class View extends \Magento\Catalog\Block\Product\View
{
private $_helper;
public function __construct(
\Wodev\Guestcheck\Helper\Data $helper,
\Magento\Catalog\Block\Product\Context $context,
\Magento\Framework\Url\EncoderInterface $urlEncoder,
\Magento\Framework\Json\EncoderInterface $jsonEncoder,
\Magento\Framework\Stdlib\StringUtils $string,
\Magento\Catalog\Helper\Product $productHelper,
\Magento\Catalog\Model\ProductTypes\ConfigInterface $productTypeConfig,
\Magento\Framework\Locale\FormatInterface $localeFormat,
\Magento\Customer\Model\Session $customerSession,
ProductRepositoryInterface $productRepository,
\Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency,
array $data = []
) {
$this->_helper = $helper;
parent::__construct($context,$urlEncoder,$jsonEncoder,$string,$productHelper,$productTypeConfig,$localeFormat,$customerSession,$productRepository,$priceCurrency,$data);
}
}
Here is my layout - Wodev\Guestcheck\view\frontend\layout\catalog_product_view.xml
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="product.info.form.content">
<referenceBlock name="product.info.addtocart" remove="true" />
<block class="Wodev\Guestcheck\Block\Product\View" name="custom.addtocart" template="Wodev_Guestcheck::product/view/addtocart.phtml"/>
</referenceContainer>
</body>
</page>
My template is not rendering. Please,help to find out why?