2

I gatting error

Recoverable Error: Argument 1 passed to Ess_M2ePro_Controller_Adminhtml_BaseController::_addContent() must be an instance of Mage_Core_Block_Abstract, boolean given, called in /var/www/app/code/community/Ess/M2ePro/controllers/Adminhtml/SupportController.php on line 72 and defined in /var/www/app/code/community/Ess/M2ePro/Controller/Adminhtml/BaseController.php on line 148

When click on sub menu in Admin panel.

Following app\code\community\Ess\M2ePro\Block\Adminhtml\Support.php file.

class Ess_M2ePro_Block_Adminhtml_Support extends Mage_Adminhtml_Block_Widget_Form_Container
{
    private $referrer = NULL;

    public function __construct()
    {
        parent::__construct();
        $this->setId('supportContainer');
        $this->_blockGroup = 'M2ePro';
        $this->_controller = 'adminhtml';
        $this->_mode = 'support';
        $this->referrer = $this->getRequest()->getParam('referrer');

     }
}

Following app\code\community\Ess\M2ePro\etc\config.xml file.

<blocks>
    <M2ePro>
        <class>Ess_M2ePro_Block</class>
    </M2ePro>
    <adminhtml>
        <rewrite>
            <page_menu>Ess_M2ePro_Block_Adminhtml_Magento_Menu</page_menu>
        </rewrite>
    </adminhtml>
 </blocks>

Following app/code/community/Ess/M2ePro/controllers/Adminhtml/SupportController.php file.

class Ess_M2ePro_Adminhtml_SupportController extends Ess_M2ePro_Controller_Adminhtml_BaseController
{
    public function indexAction()
    {
        $this->_initAction();

        $referrer = $this->getRequest()->getParam('referrer');

        if ($referrer == Ess_M2ePro_Helper_Component_Ebay::NICK) {

            $this->setPageHelpLink(Ess_M2ePro_Helper_View_Ebay::NICK);

        } elseif ($referrer == Ess_M2ePro_Helper_View_Common::NICK) {

            $components = Mage::helper('M2ePro/View_Common_Component')->getActiveComponents();
            if (count($components) == 1) {
                $this->setPageHelpLink(array_shift($components));
            }
        }

        $this->_addContent($this->getLayout()->createBlock('M2ePro/adminhtml/support'))
             ->renderLayout();
    }
}

I tried to google but still did not get proper solution.

3 Answers 3

2

My assumption is the call to createBlock('M2ePro/adminhtml/support') does not actually return a block.

This could be for a few different reasons the main ones being:

  1. The actual file is missing,
  2. The definition of blocks M2ePro is missing,
  3. The module itself is missing,

The easiest one to check would be the module. If the M2ePro module is there then have a look in the config.xml file for the node <blocks> if this node is not M2ePro then update your code to include the correct node. Finally if this file is missing then re-download the extension and install the missing files.

4
  • I already check all this thing. Please clarify what to do for this in given code ? Commented Jan 5, 2016 at 7:18
  • get xdebug installed and step through the create block function. See when it fails :) Commented Jan 5, 2016 at 7:22
  • 1
    try createBlock('M2ePro/adminhtml_support') (_ instead of / for path separator after the module alias)
    – bchatard
    Commented Jan 5, 2016 at 17:17
  • @Brice I already try createBlock('M2ePro/adminhtml_support') but not resolved. Commented Jan 6, 2016 at 3:52
1

Instead of 'M2ePro/adminhtml/support' please use 'M2ePro/adminhtml_support' change the "/" with "_"

1

tl;dr: typo of 'M2ePro/adminhtml/support' should probably be 'M2ePro/adminhtml_support'.

David states that

the call to createBlock('M2ePro/adminhtml/support') does not actually return a block

and he is correct.

The reason why is that the following chain of calls is triggered by $this->getLayout()->createBlock('M2ePro/adminhtml/support'):

Mage_Core_Model_Layout::createBlock('M2ePro/adminhtml/support')
Mage_Core_Model_Layout::_getBlockInstance('M2ePro/adminhtml/support')
Mage_Core_Model_Config::getBlockClassName('M2ePro/adminhtml/support')
Mage_Core_Model_Config::getGroupedClassName('block', 'M2ePro/adminhtml/support')

Inside getGroupedClassName() the string M2ePro/adminhtml/support is explode()d on the /, but only the first two array values (M2ePro and adminhtml) are used. M2ePro is correctly resolved according to configuration, but the $class bit is just adminhtml rather than adminhtml_support, which I'm assuming was the intention.

1
  • how the heck did I miss that :( Commented Jan 5, 2016 at 17:27

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