0

I am using Mangeto 1.9.1

I am trying to display some custom product attributes in the admin sales order view page. If i have to point it more, i am talking about this page: www.yourmagentostore.com/index.php/admin/sales_order/view/order_id/3/key/271c3dbb00b40c759098c70844b42e58/

So there i found a table which display the name of the purchased product.

I need something simple, i need to display below this name the custom attribute.

Here is the code that i found for this tablle:

    <?php $_items = $this->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) ?>
        </tbody>
    <?php endforeach; ?>

This code is located: app\design\adminhtml\default\default\template\sales\order\view\items.phtml

This bunch of code is holding the table with the name, price and such of the product. So that's what making me think that i have to add somehow here the code for the custom attribute so i can display it.

The name of the custom attribute is ext_image

As i display the custom variable in the product view page:

<?php 
$_product = $this->getProduct();
echo $_product->getExtImage(); 
?>

When i execute this code in the admin sales order view page it's not displaying the custom attribute.. So guys can you please help me display this custom attribute in this page ?

Thanks!

2 Answers 2

1

The template file for the "name" column in the sales backend is app/design/adminhtml/default/sales/items/column/name.phtml

Working with that file, you will be able to what you are after.

To avoid core changes, i'd suggest creating a module with a layout update

    <adminhtml_sales_order_view> 
        <reference name="order_items"> 
            <action method="addColumnRender">
                <column>name</column>
                <block>adminhtml/sales_items_column_name</block>
                <template>module_name/sales/items/column/name.phtml</template>
            </action>
            <action method="addColumnRender">
                <column>name</column>
                <block>adminhtml/sales_items_column_name_grouped</block>
                <template>module_name/sales/items/column/name.phtml</template>
                <type>grouped</type>
            </action>
        </reference> 
    </adminhtml_sales_order_view>

You can also attach this override to other adminhtml_sales layouts, using the same reference/action methods above...

<adminhtml_sales_order_invoice_new /> <adminhtml_sales_order_invoice_updateqty /> <adminhtml_sales_order_invoice_view /> (use invoice_items reference for this layout) <adminhtml_sales_order_shipment_new /> <adminhtml_sales_order_shipment_view /> (use shipment_items reference for this layout) <adminhtml_sales_order_creditmemo_new /> <adminhtml_sales_order_creditmemo_updateqty /> <adminhtml_sales_order_creditmemo_view /> (use creditmemo_items reference for this layout)

Hope that helps

3
  • you proberly also need to load the product attribute data if it's not already loaded into the $_product object You can do the following... Mage::getModel('catalog/product')->load($_product->getId())->getMyAttribute() or (may not work) try preloading the attribute by setting "Used in Product Listing" to "yes"
    – Matthew
    Commented Jul 26, 2014 at 0:30
  • No it seems the app/adminhtml/default/sales/items/columns/name.phtml is not the file which brings up the name in www.yourmagentostore.com/index.php/admin/sales_order/view/order_id/3/key/271c3dbb00b40c759098c70844b42e58/ page column... Please help!
    – Venelin
    Commented Jul 26, 2014 at 19:39
  • correct pathname is app/design/adminhtml/default/sales/items/column/name.phtml
    – Matthew
    Commented Jul 27, 2014 at 9:11
0

once you have created your module you should be able to use this to get the required attribute in app/adminhtml/default/sales/items/columns/name.phtml

<?php $product = Mage::getModel('catalog/product')->loadByAttribute('sku', $_item->getSku(), array('yourattribute')); echo $product->getYourAttribute(); ?>

i put it after:

<div><strong><?php echo $this->helper('sales')->__('SKU') ?>:</strong> <?php echo implode('<br />', Mage::helper('catalog')->splitSku($this->htmlEscape($this->getSku()))); ?></div>

on about line 35.

Hope this helps i spent 2 days trying to get it right.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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