I am trying to display my custom attribute value on admin order - Items Ordered block. It will show points earned for each product just like as it shows SKU
and other information. The attribute value is saved in sales_flat_quote_item
and sales_flat_order_item
tables.
Namespace/Modulename/Block/Adminhtml/Sales/Order/View/Items/Renderer/Default.phtml
<?php
class Namespace_Modulename_Block_Adminhtml_Sales_Order_View_Items_Renderer_Default extends Mage_Adminhtml_Block_Sales_Order_View_Items_Renderer_Default
{
}
?>
app/design/adminhtml/design/design/layout/namespace/modulename.xml
<adminhtml_sales_order_view>
<reference name="order_items">
<action method="addItemRender"><type>default</type>
<block>sales/order_item_renderer_default</block>
<template>namespace/modulename/sales/order/items/renderer/default.phtml</template>
</action>
</reference>
</adminhtml_sales_order_view>
app/design/adminhtml/default/default/template/namespace/modulename/sales/order/view/items/rederer/default.phtml
<?php $finalPointsEarned = ($_item->getCustomerProductPoints() * $_item->getQtyOrdered()); ?>
<div class="product-cart-sku">
<span style="color: #d4af37; font-weight: bold;"><?php echo $this->__('Points Earned:'); ?>
<?php echo $finalPointsEarned ?>
</span>
</div>
Executing above code gives below exception
Invalid method Mage_Sales_Block_Order_Item_Renderer_Default::addColumnRender(Array
(
[0] => qty
[1] => adminhtml/sales_items_column_qty
[2] => sales/items/column/qty.phtml
)
)
Changing <adminhtml_sales_order_view>
to <sales_order_view>
does not give any output and custom prod attribute is not displayed.
Attempt Two:
<adminhtml_sales_order_view>
<reference name="order_items">
<action method="addColumnRender">
<column>NORTH FACE</column>
<block>adminhtml/sales_items_column_name</block>
<template>modulename/sales/items/column/name.phtml</template>
</action>
</reference>
</adminhtml_sales_order_view>
added my custom code in name.phtml
, still no output.
SKU
, Size
and other values ?The easiest and most efficient way is to create a custom theme for a store admin, copy-paste the requested template in there and rewrite the output the way you want to have it.
Thus you will be able to fully customize it. Also, this approach will lower the risk of getting errors and provide you with the ability to customize any templates (including invoices, credit memos, etc.)
Have a look:
app/etc/local
xml or in your extension config settings): Note that the custom attribute is usually entered via get method. If you are having any trouble with that, just check if it exists for the chosen item in the database. In the sales_flat_order_item
table
find all the items related to the chosen order and make sure that it has the value, different from null
. This is how it worked in my case: