cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2.2.6 Fatal error: Uncaught Error: Call to a member function dispatch() on null

Magento 2.2.6 Fatal error: Uncaught Error: Call to a member function dispatch() on null

I get the next message:

Fatal error: Uncaught Error: Call to a member function dispatch() on null in /var/www/html/compstore/vendor/magento/framework/Model/ResourceModel/Db/Collection/AbstractCollection.php:531 Stack trace: #0 /var/www/html/compstore/vendor/magento/framework/Data/Collection/AbstractDb.php(571): Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection->_beforeLoad() #1 /var/www/html/compstore/vendor/magento/framework/Data/Collection/AbstractDb.php(559): Magento\Framework\Data\Collection\AbstractDb->loadWithFilter(false, false) #2 /var/www/html/compstore/vendor/magento/framework/Data/Collection.php(831): Magento\Framework\Data\Collection\AbstractDb->load() #3 /var/www/html/compstore/app/code/Djile/Sample/view/frontend/templates/list.phtml(6): Magento\Framework\Data\Collection->getIterator() #4 /var/www/html/compstore/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/var/www/html/c...') #5 /var/www/html/compstore/vendor/magento/framework/View/Element/Template.php(270): Magento\Framework\View\Template in /var/www/html/compstore/vendor/magento/framework/Model/ResourceModel/Db/Collection/AbstractCollection.php on line 531

IDTitle

 

Here is List.phtml

<table>
<tr>
<td>ID</td>
<td>Title</td>
</tr>
<?php foreach($block->getDemoItems() as $item): ?>
<tr>
<td><?php echo $item->getId(); ?></td>
<td><?php echo $item->getTitle(); ?></td>
</tr>
<?php endforeach; ?>
</table>
2 REPLIES 2

Re: Magento 2.2.6 Fatal error: Uncaught Error: Call to a member function dispatch() on null

Please mention the layout xml file and the block class file you are using.

Re: Magento 2.2.6 Fatal error: Uncaught Error: Call to a member function dispatch() on null

Please share the code of your block file which you are using for your List.phtml

Was my answer helpful? You can Click Kudos/Accept As Solution.
200+ professional extensions for M1 & M2 with free lifetime updates!