Uncaught Error: Call to a member function dispatch() on null

主要问题是因为构造函数的类没有继承父类,需要更新构造函数如下:

public function __construct(
    \Magento\Framework\View\Element\Template\Context $context,
    \Magento\Customer\Model\Session $customerSession,  
    \Magento\Framework\ObjectManagerInterface $objectManager,
    array $data = []
 ) {
    parent::__construct($context, $data);
    $this->customerSession = $customerSession;
    $this->_objectManager = $objectManager;
  }

你可能感兴趣的:(magento2)