1

I just want item id after every item so I could create some buttons get some information from database but it is always showing id of first item this is my xml

<layout version="0.1.0">
<adminhtml_sales_order_view>
    <reference name="order_item_extra_info">
        <block type="core/template" name="cgorder_wrap_container" template="customsales/sales/cgorder_details_container.phtml">
            <!-- Replace it with your OWN block -->
            <block type="core/template" name="own_real_block" template="customsales/sales/cgorder_details.phtml" />
        </block>
    </reference>
</adminhtml_sales_order_view>

this is my parent template file

<tr>
<td><?php echo $this->getChildHtml();?></td>
<td colspan="8"></td></tr>

this is my child template file

<?php
$id = $this->getParentBlock()->getParentBlock()->getItem()->getID();
echo "id is ".$id;
?>

enter image description here

1
  • You will have the problem with every patch still, because the patched file is not used, but yours, when you have another template file, either due to overwrite or to change. But at least you don't lose the changes :-) magento.stackexchange.com/q/79132/217 Apr 15, 2016 at 11:05

1 Answer 1

0

Try to add your block as the child of the <block type="core/text_list" name="order_item_extra_info"></block>. It should look like this:

Layout:

<adminhtml_sales_order_view>
    <reference name="order_item_extra_info">
        <block type="core/template" name="own_name" template="sales/test.phtml" />
    </reference>
</adminhtml_sales_order_view>

Template sales/test.phtml (wrapper, table structure):

<tr>
    <td><?php echo $this->getParentBlock()->getItem()->getId();?></td>
    <td colspan="8"></td>
</tr>

Here result (where 807 and 809 is item ids):
Result

PS: Do not forget to save table structure in the template.

9
  • Thanks. I have got the HTML one more thing can you tell me how can I retrieve that item array in test2.phtml I tried $_item = $this->getItem(); but it did not work..
    – Atharuddin
    Apr 15, 2016 at 11:35
  • @Atharuddin Try something like this: $item = $this->getParentBlock()->getParentBlock()->getItem(); Apr 15, 2016 at 11:47
  • Thank you so much. you saved me from hours of searching....
    – Atharuddin
    Apr 15, 2016 at 11:55
  • @Atharuddin you’re welcome :) Apr 15, 2016 at 11:58
  • I just realised that it only gets one item and it is displaying info of that item repeatedly. :(
    – Atharuddin
    Apr 19, 2016 at 16:49

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