0

In my backend controller I use the following code to render a custom block.

 $this->_title($this->__('Inventar'));
 $this->loadLayout();
 $this->_setActiveMenu('psp_inventorymanager');
 $this->_addContent($this->getLayout()->createBlock('psp_inventorymanager/adminhtml_importstatus'));
 $this->_initLayoutMessages('customer/session');
 $this->renderLayout();

But the _addContent line does not work. It works on a local magento install but not on the main site. This is the content of the block's _toHtml():

 public function _toHtml()
 {
 $html = parent::_toHtml();
 $session = Mage::getSingleton('core/session');
 echo '<style>
 .list-with-heading h3{
 font-weight: normal;
 }
 .list-success {
 background: green;
 }
 .list-fail {
 background: red;
 }
 .list-oldqty {
 background: yellow;
 }
 .list-with-heading {
 background: #00BFFF;
 border: 1px solid #000;
 padding: 10px;
 }
 .auto {
 max-height: 150px;
 overflow: auto;
 border: 1px solid #000;
 padding: 10px;
 }
 </style>';
 echo '<div class="list-with-heading"><h3>Successful imports: </h3><ul class="list-success auto">';
 foreach ($session->getInventoryImportSuccess() as $key => $value) {
 echo '<li>'. $key .'</li>';
 }
 echo '</ul></div>';
 echo '<div class="list-with-heading"><h3>Failed imports [SKU not found]: </h3><ul class="list-fail auto">';
 foreach ($session->getInventoryImportFail() as $key => $value) {
 echo '<li>'. $key .'</li>';
 }
 echo '</ul></div>';
 echo '<div class="list-with-heading"><h3>Failed imports [QTY not changed]: </h3><ul class="list-oldqty auto">';
 foreach ($session->getInventoryImportOldQty() as $key => $value) {
 echo '<li>'. $key .'</li>';
 }
 echo '</ul></div>';
 $html .= "teeeeeeeeeeeeest";
 return $html;
 }

Edit: I have looked at the system.log and createBlock fails and returns false instead of the block.

asked May 3, 2016 at 11:15

1 Answer 1

0

I feel silly now. I traced createBlock and saw that I had a typo in my block's naming. I had to change

->createBlock('psp_inventorymanager/adminhtml_importstatus')

to this

->createBlock('psp_inventorymanager/adminhtml_importStatus')
answered May 3, 2016 at 12:10

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.