0

i'm trying to add block to the admin order view page in magento

my layout update is

 <?xml version="1.0"?>
<layout>
    <adminhtml_sales_order_view>
        <reference name="order_tab_info">
            <block before="order_tab_info" type='vendor/additonal' name="ama_additonal_data" template="vendor/additonal.phtml" >
                <action method="setChild">
                    <name>order_info</name>
                    <block>order_info</block>
                </action>
            </block>
            <action method="setChild">
                <name>order_info</name>
                <block>ama_additonal_data</block>
            </action>
        </reference>
    </adminhtml_sales_order_view>
</layout>

my block is

class Vendor_ModuleName_Block_Sales_Order_View_AdditonalData extends Mage_Adminhtml_Block_Sales_Order_Abstract{

}

if i make the following in the block file

public function __construct(){
 var_dump('hey');
 die;
}

the page stops for showing that but it looks that my block doesn't render

why?

Eli Y
  • 877
  • 16
  • 41
  • your two child blocks has same `name`. give different names. You may also want to use `getChildHtml()` method for renders your block – Rajeev K Tomy Jul 07 '14 at 01:42
  • That's suppose to be an hack to move the order info child to be my child and replace it with my block. Than show order info. – Eli Y Jul 07 '14 at 05:58
  • can you show me the config.xml file of your module ? atleast the `block` defintion ? – Rajeev K Tomy Jul 07 '14 at 06:31

1 Answers1

1

You layout code is no longer going to work. Since it has some errors in it. I will point out what I can see.

  1. Block of described type does not exist

    You block type is vendor/additonal. Obviously it is a custom block that is defining by a custom module. It means you need to have a block with class name Vendor_Modulename_Block_Additional that should define in the location app/code/local/Vendor/Modulename/Block/Additional.php. Now here, your block have a name Vendor_ModuleName_Block_Sales_Order_View_AdditonalData (Location is unknown, you didn't provide). That means the block that you defined in layout is undefined and magento will throw some error in your log(if you activated your logs).

  2. Unnecessary before declaration

    See the answer of alanstorm for this THREAD. In short, you can define a before attribute in two cases only. Out of them, most frequently used case is the first one. That is

    your block should comes under a parent block which is of type core/text_list.

    Here the parent block that holds your custom block is order_tab_info block. It is a magento core defined block. So your before attribute is not going to work.

  3. You are trying to make your custom block as parent of a block, that holding your block !!!

    In your block defintion, you are trying to set order_tab_info block as a child of your block. Note that you are already staying inside order_tab_info block. That means your block is now a child of order_tab_info block. Didn't get what I have potrait? OK. consider a situation where a lady carries her child in her womb. Suppose the child is saying..

    "Hey I am the actual mother of my mother!!!!!"

    See.There is no logic in it. Again inside order_tab_info block, you are again redefining your custom block as its child block. It is just like, if the mother(in the above example) says

    "Hey every one, the child that I am carrying now is my child"

    Do you think, is it relevant to redefine it? Every one can understand that the child that carrying by that lady is obviously her child and she is her mother. No need for redefining it. So what you are trying to do here is completely wrong.

Try to make a good idea on magento's layout structure.

Good Luck.

Community
  • 1
  • 1
Rajeev K Tomy
  • 2,206
  • 1
  • 18
  • 35