0

TO show a custom attribute

I have created a custom attribute now i want to show it on in Items Ordered section for every product in sales -> order section.

root\app\design\adminhtml\default\default\template\sales\order\view\items.phtml i found that above file shows the name Like Product, items Status and all

and the data is i think coming from below code

 <?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; ?>

Now from here i have no idea from where the data is populated in that tabs.

<?php echo "custom_attribute".$_order->getData('custom_attribute'); ?>

even this code shows nothing.

if I print_r($_item); the $_item in

C:\xampp\htdocs\m1\app\design\adminhtml\default\default\template\sales\order\view\items\renderer\default.phtml

i can clearly see the custom_attribute but dont no how to show .

weee_tax_applied_row_amnt] => 0.0000
            [base_weee_tax_applied_row_amount] => 0.0000
            [weee_tax_applied_amount] => 0.0000
            [weee_tax_applied_row_amount] => 0.0000
            [weee_tax_applied] => a:0:{}
            [weee_tax_disposition] => 0.0000
            [weee_tax_row_disposition] => 0.0000
            [base_weee_tax_disposition] => 0.0000
            [base_weee_tax_row_disposition] => 0.0000
            [custom_attribute] => customattr

I found that echo $this->getColumnHtml($_item, 'name'); this line gave product name and sku but if i do same with my attribute name as below. nothing is shown.

echo $this->getColumnHtml($_item, 'custom_attribute');

1

Finally i found the solution. So posting as answer.

1) First i created a custom_attribute
2) To save my custom_attribute in sales_flat_order_item i found this link https://www.atwix.com/magento/custom-product-attribute-quote-order-item/

3)To check we can print_r($items); in this file C:\xampp\htdocs\m1\app\design\adminhtml\default\default\template\sales\order\view\items\renderer\default.phtml

4) To show the value of custom_attribute i used <?php echo"<b>HSN :</b>".$_item->getcuctomAttrNameHere(); ?>

May be this will not be a good solution , but to reach this point it took my day.

  • Good job Saurabh. it will be useful like us. – Nagaraju K Jun 17 '17 at 12:33

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.