I've got a custom module, Mirasvit Ticket, and I've added a tab for order information.

I'd like to be able to place pretty much the entire order view into that tab. However, I'm unable to get the blocks to show up.

Here's what I've pasted into my custom view pulled from app/design/adminhtml/default/default/template/sales/order/view.phtml

The file I'm working on is:


<div class="grid np">
  <div class="hor-scroll table-responsive">
    <table cellspacing="0" class="data order-tables">
        <col />
        <col width="1" />
        <col width="1" />
        <col width="1" />
        <col width="1" />
        <col width="1" />
        <col width="1" />
        <col width="1" />
        <col width="1" />
        <col width="1" />
            <tr class="headings">
                <th><?php echo $this->helper('sales')->__('Product') ?></th>
                <th><span class="nobr"><?php echo $this->helper('sales')->__('Item Status') ?></span></th>
                <th><span class="nobr"><?php echo $this->helper('sales')->__('Original Price') ?></span></th>
                <th><?php echo $this->helper('sales')->__('Price') ?></th>
                <th class="a-center"><?php echo $this->helper('sales')->__('Qty') ?></th>
                <th><?php echo $this->helper('sales')->__('Subtotal') ?></th>
                <th><span class="nobr"><?php echo $this->helper('sales')->__('Tax Amount') ?></span></th>
                <th><span class="nobr"><?php echo $this->helper('sales')->__('Tax Percent') ?></span></th>
                <th><span class="nobr"><?php echo $this->helper('sales')->__('Discount Amount') ?></span></th>
                <th class="last"><span class="nobr"><?php echo $this->helper('sales')->__('Row Total') ?></span></th>
        <?php $_items = $_order->getItemsCollection() ?>
        <?php $i=0;foreach ($_items as $_item):?>
            <?php if ($_item->getParentItem()) continue; else $i++;?>
            <tbody class="<?php echo $i%2?'even':'odd' ?>">
                <?php echo $this->getItemHtml($_item) ?>
                <?php echo $this->getItemExtraInfoHtml($_item) ?>
        <?php endforeach; ?>

I'm thinking that my problem is that $this is clearly different from the $this in that file.

Is there a way I can just load the blocks directly?

  • when you want to see where your $this comes from do get_class($this)
    – Nickool
    Dec 7 '16 at 23:26
  • what is the name of your phtml file, did you add a new file or you just changed one of the files? your path file is not showing it
    – Nickool
    Dec 7 '16 at 23:29
  • My path file is in a custom module but it's in: app/design/adminhtml/default/default/template/mst_helpdesk/ticket/edit/tab/orderinfo.phtml
    – Ryan Cady
    Dec 7 '16 at 23:44
  • I can see $this is used to call helper, so it wouldn't hurt much being different. How have you defined $_order in there? I don't see you have assigned anything to it? Also, are you seeing at least heading parts? Can you show your layout code too? Dec 7 '16 at 23:48
  • just use Mage::helper('mynamespace_Mirasvit /data') instead whatever you have change those
    – Nickool
    Dec 7 '16 at 23:50

To get full working items table in your custom module page, you should add this to your layout.

                 <block type="adminhtml/sales_order_view_items" name="order_items" template="sales/order/view/items.phtml">
                    <action method="addItemRender"><type>default</type><block>adminhtml/sales_order_view_items_renderer_default</block><template>sales/order/view/items/renderer/default.phtml</template></action>
                    <action method="addColumnRender"><column>qty</column><block>adminhtml/sales_items_column_qty</block><template>sales/items/column/qty.phtml</template></action>
                    <action method="addColumnRender"><column>name</column><block>adminhtml/sales_items_column_name</block><template>sales/items/column/name.phtml</template></action>
                    <action method="addColumnRender"><column>name</column><block>adminhtml/sales_items_column_name_grouped</block><template>sales/items/column/name.phtml</template><type>grouped</type></action>
                    <block type="core/text_list" name="order_item_extra_info" />

Then, you can call getItemHtml().

It's hard to tell where exactly you should add above code without seeing your layout file. Have a look at sales.xml layout file. It will give you some idea.

All you need to do is, somehow your block should extend Mage_Adminhtml_Block_Sales_Items_Abstract, so that you can call $this->getItemHtml() function. In default view.phtml, $this means Mage_Adminhtml_Block_Sales_Order_View_Items object which extends abstract class.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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