cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Attribute in Invoice Admin - Magento 1.9

Custom Attribute in Invoice Admin - Magento 1.9

I try to add a custom attribuite in invoice admin, but show me blank. The attribute code is ncm.

$_order = $this->getOrder();
$_invoice = $this->getInvoice();
$_items = $this->getInvoice()->getAllItems();
$i=0;foreach ($_items as $item) {
$ncm = $item->getNcm();
echo $ncm;
5 REPLIES 5

Re: Custom Attribute in Invoice Admin - Magento 1.9

Hello,

 

I have two suggestions for you:

1. Easy to do.

We will load all attributes using: 

$product = Mage::getModel('catalog/product')->load($item->getProductId();
$product->getData('ncm');

However, not correct if product is deleted.

 

2. Default Community Edition Magento has eight different types of EAV objects:
Customer, Customer Address, Catalog Category, Catalog Product, Order, Invoice, Credit Memo, Shipment.

Here is the flow of Magento Order process:

 

Before pressing Place Order button on Onepage checkout, all necessary information are stored in Quote tables, and then will be transferred to Order tables. After making invoice, the necessary information for an invoice will store in invoice tables.

Shortly, we can create attribute Ncm for Quote, Order, Invoice object. And then call it by $item->getNcm();

I have done a tutorial:

http://www.boolfly.com/add-custom-fields-to-order-magento-part-2/ 

Problem solved? Click Accept as Solution!

Re: Custom Attribute in Invoice Admin - Magento 1.9

I try add the code

 

product = Mage::getModel('catalog/product')->load($item->getProductId();$product->getData('ncm');

in app\design\adminhtml\default\default\template\sales\order\invoice\view\items.phtml but still not show the NCM attribute value.

 

Re: Custom Attribute in Invoice Admin - Magento 1.9

Hello,

 

You set Attributes > Manage Attribute Sets ?

 

 

And you sure that your products have Ncm values. I also saw your code lines missed $ sign: product -> $product 

You need to add echo $product->getData('ncm')

If still not working, please post your code from app\design\adminhtml\default\default\template\sales\order\invoice\view\items.phtml

Problem solved? Click Accept as Solution!

Re: Custom Attribute in Invoice Admin - Magento 1.9

Yes, I add NCM in default attribute set.

 

see: http://s2.postimg.org/d0mj32h4p/attribute_set.jpg

 

attribute: http://s21.postimg.org/bs1om268n/attribute.jpg

 

product on backend: http://postimg.org/image/j3jfe2ge9/

 

product on frontend: http://s13.postimg.org/x1tpo9d8n/product_frontend.jpg

 

invoice on admin: http://s10.postimg.org/8kux5duw9/invoice.jpg

 

items.phtml file: http://s1.postimg.org/9nseztsqn/items.jpg

 

* if I use the code posted first, the result it's same.

Re: Custom Attribute in Invoice Admin - Magento 1.9

Hello @bestartbr  How did you added the custom attribute in invoice backend??
Did you also outputted the custom attribute in the invoice pdf ??