In my Magento 2 front page, if i click on the categories/subcategories menu, i get
Call to a member function dispatch() on null in C:\xampp\htdocs\magento2x\magento2\lib\internal\Magento\Framework\View\Element\AbstractBlock.php on line 644.
My system.log says:
Cache file with merged layout: LAYOUT_frontend_STORE1_36f1b068ec7ccf4878f9284dd1137afd1 and handles catalog_product_prices: Please correct the XML data and try again. [] []
I am actually migrating my 1x magento to 2x.
Could you please help with the corresponding code for di.xml under etc.
My updated di.xml is as
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!--Overrride for Block catalog rewrite product list toolbar -->
<preference for="Magento\Catalog\Block\Product\ListProduct" type="Vendor\Module\Block\Catalog\Product\ListProduct" />
<preference for="ToolbarModel" type="Vendor\Module\Block\Catalog\Product\SearchList\Toolbar" /> <!--ToolbarModel: alias for Magento\Catalog\Model\Product\ProductList\Toolbar -->
<!--Override for Block catalog Search layer -->
<preference for="\Magento\LayeredNavigation\Block\Navigation" type="Vendor\Module\Block\CatalogSearch\Layer" />
<!-- Override model: Catalog Resource-->
<preference for="Magento\Catalog\Model\ResourceModel\Product\Collection" type="Vendor\Module\Model\Catalog\Resource\Product\Collection" />
If i search for products by clicking category menu, i get the above mentioned error? Is it cause of my incomplete di xml file?
-
Looks like the problem in you Tagalys\Tglssearch\Block\Catalog\Product\ListProduct or Tagalys\Tglssearch\Block\Catalog\Product\SearchList\Toolbar class constructor. Can you add it to question?KAndy– KAndy2016年06月21日 09:16:18 +00:00Commented Jun 21, 2016 at 9:16
-
added ListProduct, Toolbar and dixmlSushivam– Sushivam2016年06月21日 09:27:06 +00:00Commented Jun 21, 2016 at 9:27
-
Kandy , any update ?Sushivam– Sushivam2016年06月21日 10:21:06 +00:00Commented Jun 21, 2016 at 10:21
1 Answer 1
You can find this problem by self if you try to run Magento static and integrity test.
Problem in \Magento\Catalog\Block\Product\ProductList\Toolbar constructor. You do not pass all parameters to the parent class.
Replace
public function __construct(
\Vendor\Module\Helper\Data $tglssearchHelper
//\Magento\Framework\View\Element\Template\Context $context,
//array $data=[]
) {
$this->tglssearchHelper = $tglssearchHelper;
//parent::__construct($context,$data);
}
on
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Catalog\Model\Session $catalogSession,
\Magento\Catalog\Model\Config $catalogConfig,
ToolbarModel $toolbarModel,
\Magento\Framework\Url\EncoderInterface $urlEncoder,
ProductList $productListHelper,
\Magento\Framework\Data\Helper\PostHelper $postDataHelper,
array $data
) {
parent::__construct(
$context,
$catalogSession,
$catalogConfig,
$toolbarModel,
$urlEncoder,
$productListHelper,
$postDataHelper,
$data
);
$this->tglssearchHelper = $tglssearchHelper;
}
(see full class name in parrent class)