I am trying to add a custom block to the admin order view page and am doing this via an observer using the event core_block_abstract_to_html_before
. I am using the giftmessage block, clone it and add it as a child in my own block
Observer code:
public function insertAdminBlock($observer)
{
$_block = $observer->getBlock();
$_type = $_block->getType();
if ($_type == 'adminhtml/template')
{
if ($_block->getChild('order_giftmessage'))
{
$_child = clone $_block;
$_child->setType('adminhtml/sales_order_view_info');
$_block->setChild('giftmessage', $_child);
$_block->setTemplate('mymodules/adminview.phtml');
}
}
}
the template looks like this:
<div class="entry-edit">
<div class="entry-edit-head">
<h4><?php echo Mage::helper('sales')->__('Custom Value') ?></h4>
</div>
<fieldset>
<tr>
<td class="label"><label><strong><?php echo Mage::helper('sales')->__('Custom Value:') ?></strong></label></td>
<td class="value"><?php var_dump($this->getOrder()->getValue())?></td>
</tr>
</fieldset>
</div>
<?php echo $this->getChildHtml('giftmessage') ?>
The block gets inserted between the Payment/Shipping Method and Items block.
However the function $this->getOrder
does not work in my block as the result is empty. Any ideas what I am missing?