0

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?

3
  • 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
    Commented Jun 21, 2016 at 9:16
  • added ListProduct, Toolbar and dixml
    – Sushivam
    Commented Jun 21, 2016 at 9:27
  • Kandy , any update ?
    – Sushivam
    Commented Jun 21, 2016 at 10:21

1 Answer 1

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)

3
  • Its still showing the same error after replacing
    – Sushivam
    Commented Jun 21, 2016 at 10:58
  • I have updated Toolbar with the constructors still has dispacth() error
    – Sushivam
    Commented Jun 21, 2016 at 11:05
  • Verify other blocks
    – KAndy
    Commented Jun 21, 2016 at 11:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.