Template doesn't set from my block.
My 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\ListProduct" type="Kite\Boxes\Block\Rewrite\Product\ListProduct" />
</config>
My Block File is,
<?php
namespace Kite\Boxes\Block\Rewrite\Product;
class ListProduct extends \Magento\Catalog\Block\Product\ListProduct
{
protected function _construct()
{
$this->setTemplate('Kite_Boxes::catalog/product/list.phtml');
}
}
Error occurred like,
Fatal error: Uncaught TypeError: Argument 1 passed to Magento\Catalog\Block\Product\ListProduct::__construct() must be an instance of Magento\Catalog\Block\Product\Context, none given, called in /var/www/vhosts/goweb-dev01.site/httpdocs/var/generation/Kite/Boxes/Block/Rewrite/Product/ListProduct/Interceptor.php on line 14 and defined in /var/www/vhosts/goweb-dev01.site/httpdocs/vendor/magento/module-catalog/Block/Product/ListProduct.php:66 Stack trace: #0 /var/www/vhosts/goweb-dev01.site/httpdocs/var/generation/Kite/Boxes/Block/Rewrite/Product/ListProduct/Interceptor.php(14): Magento\Catalog\Block\Product\ListProduct->__construct() #1 /var/www/vhosts/goweb-dev01.site/httpdocs/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(73): Kite\Boxes\Block\Rewrite\Product\ListProduct\Interceptor->__construct() #2 /var/www/vhosts/goweb-dev01.site/httpdocs/vendor/magento/framework/ObjectManager/ObjectManager.php(57): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Kite\\Boxes\\Bloc...', Array) #3 in /var/www/vhosts/goweb-dev01.site/httpdocs/vendor/magento/module-catalog/Block/Product/ListProduct.php on line 66
Does anyone have idea about this problem?
Best Answer
There is no issue you just need to delete
generated
folder and then check.If the cache is enabled then you need to refresh cache using
Update your
di.xml
with this code,Create Plugin
Kite/Boxes/Plugin/ListProduct.php
After this you can check your productlist page.