Let me preface with the fact that getLayout->createBlock->toHtml continue to mystify me.
There is a line of code that is throwing an error:
$this->getLayout()->createBlock('distributor/adminhtml_distributors_edit_tab_chat')->toHtml()
The result states that
Fatal error: Call to a member function toHtml() on a non-object in....
Doing a gettype() on `$this->getLayout()->createBlock('distributor/adminhtml_distributors_edit_tab_chat')
It shows that it's returning a boolean rather than an object.
I am trying to understand why this would return a boolean rather than the object that it is expecting.
I did search the error on Google, with the results stating to make sure that the block exists. As far as I can tell, it does. I was hoping it would be simple but never seems to be my luck.
The system is setup to run multiple sites, the sites that don't have database entries associated with this block allow the page to display correctly. Even after deleting the database entries, clearing the cache and retesting the page, the same error occurs.
Thank you for your time and assistance.
Update 01
Based on the replies, I am adding more (please let me know what else would be necessary to assist).
- This is a code base that already exists.
- This is code that had been running in production without incident.
The code below exists in app/code/local/codebase/Distributor/Block/Adminhtml/Distributors/Edit/Tabs.php
$this->addTab('distributor_chat_section', array(
'label' => Mage::helper('distributor')->__('Live Chat'),
'title' => Mage::helper('distributor')->__('Live Chat'),
'content' => $this->getLayout()->createBlock('distributor/adminhtml_distributors_edit_tab_chat')->toHtml()
));
distributor/adminhtml_distributors_edit_tab_chattoo?$this->getLayout()returning the false, the issue was with the full$this->getLayout()->createBlock(). In ...Chat.php there is an api call in which the endpoint is returning a 301. Unfortunately ajson_decodecall was not wrapped in try/catch and the 301 return is not json. STILL, I don't understand how the$this->getLayout()returns false when the issue is with the creatBlock() call, order of operations doesn't make sense to me.app/code/local/codebase/Distributor/Block/Adminhtml/Distributors/Edit/Tabs.php. Check this github.com/OpenMage/magento-mirror/blob/…, in this core core team has used very similar perspective. Check if you are extending thisMage_Adminhtml_Block_Widget_Tabsclass. Also, please add full file code.