0

I would like to know the best method for adding additional data to the sales order screen.

I would like to add an additional line below 'Purchased From'

Magento admin panel

Not sure if I should be editing the templates, editing blocks or extending some logic - thanks!

3 Answers 3

2

The solution depends on kind of your customization. If there is possibility to parse your template and insert necessary block by string functions better use event 'core_block_abstract_to_html_after'

<adminhtml>
    <events>
        <core_block_abstract_to_html_after>
            <observers>
                <update_sales_order_info>
                    <model>module/observer</model>
                    <method>updateSalesOrderInfo</method>
                </update_sales_order_info>
            </observers>
        </core_block_abstract_to_html_after>
    </events>
</adminhtml>

Then create your observer get your $html and using str_replace add your block. For example we need some block to account information.

class Module_Vendor_Module_Observer
{
    public function updateSalesOrderInfo($observer)
    {
        if($observer->getBlock() instanceof Mage_Adminhtml_Block_Sales_Order_View_Info)
        {
            $html = $observer->getTransport()->getHtml();
            $html = str_replace('<!--Account Information-->', '<!--Account Information--><div>Some text</div>', $html);
            $observer->getTransport()->setData('html', $html);
        }
    }
}

Sure maybe its hard or even impossible add your block by my way. But if you can - I recommend you use it.

The main advantages:

  • If some 3rd party module will rewrite the same class - will not appear rewrite conflict and you don't need to merge classes.
  • If 3rd party module will need to replace this template there is a possibility that your update will not disappear (if your search string will exist in 3rd party module template)
1

Without knowing exactly what you want to do with this the template can be found at app/design/adminhtml/default/default/template/sales/order/view/info.phtml If you simply want to display some extra information that is already stored etc then you can add some layout.xml changes that update this template to your own template and edit it as you wish.

<layout version="0.1.0">
    <adminhtml_sales_order_view>
        <reference name="order_info">
            <action method="setTemplate">
                <template>your/custom/order/view/info.phtml</template>
            </action>
        </reference>
    </adminhtml_sales_order_view>
</layout>
0

Check this tutorial >> http://sohelrana09.wordpress.com/2011/06/24/how-to-overwrite-sales-view-order-phtml-file-in-magento/

It will be help for you.

1
  • 3
    A link-only answer is not the best answer. Please revise to include (attributed) relevent content from the source.
    – philwinkle
    Mar 21, 2014 at 16:38

Your Answer

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

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