0

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.

enter image description here

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.

  1. How do I display the value of custom product attribute on Items ordered block ?
  2. How do I display the same value of admin Invoice order details page ?
  3. Is above, the best practice/method to display custom attribute on admin order/invoice/refund pages just like it displays SKU, Size and other values ?
  • have you saved custom attributes values in database table sales_flat_quote_item, sales_flat_order_item? or Use directly in catalog product table? – Abdul Jan 11 '16 at 6:28
  • Yes they are being save in sales_flat_quote_item, sales_flat_order_item tables. – Slimshadddyyy Jan 11 '16 at 6:31

Your Answer

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

Browse other questions tagged or ask your own question.