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">
    <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" />

this is my parent template file

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

this is my child template file

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

enter image description here

  • 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 – Fabian Blechschmidt Apr 15 '16 at 11:05

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:


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

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

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

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

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

  • 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 '16 at 11:35
  • @Atharuddin Try something like this: $item = $this->getParentBlock()->getParentBlock()->getItem(); – Siarhey Uchukhlebau Apr 15 '16 at 11:47
  • Thank you so much. you saved me from hours of searching.... – Atharuddin Apr 15 '16 at 11:55
  • @Atharuddin you’re welcome :) – Siarhey Uchukhlebau Apr 15 '16 at 11:58
  • I just realised that it only gets one item and it is displaying info of that item repeatedly. :( – Atharuddin Apr 19 '16 at 16:49

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