Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

get an custom attribute value in the invoice pdf
 
davidh
Jr. Member
 
Total Posts:  20
Joined:  2008-03-06
 

Hello,

I’m working on the invoice pdf feature : I’m trying to customize it, and I’d like to add a custom attribute in the table.

I know that a solution to access to its value is to add in the layout the line : “<action method="addAttribute">.........." But, in my case, I don’t use any layout because the customer download directly a file. So, I don’t see how can I get my attribute value ?

Thanks for your help

 
Magento Community Magento Community
Magento Community
Magento Community
 
mzentrale1
Guru
 
Total Posts:  731
Joined:  2007-12-06
Stuttgart, Germany
 

Hi,

could you explain your needs more detailed? is this attribute a part of product model or order model or invoice model, where should this attribute diplayed? in table of product listing?

cheers

Stefan

 
Magento Community Magento Community
Magento Community
Magento Community
 
M. Calin
Jr. Member
 
Total Posts:  9
Joined:  2009-04-15
 

Hello,

I’m having the same problem too.

I’m trying to change the pdf invoice to show some custom attribute for the customer which were defined using attribute manager and i can’t get the values.

I have the order :
$order = Mage::getSingleton(’sales/order’);
$order->load($invoice->order_id);

and the customer with the standard attributes:
$customer = Mage::getSingleton(’customer/customer’);
$customer->load($order->customer_id);

All i need are the custom attributes.

Can anyone help please.
Thank you.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Uruselfei
Member
 
Avatar
Total Posts:  74
Joined:  2009-01-08
Tallinn, Estonia
 

hello,

did anyone found solution for adding custom attributes to PDF?

 
Magento Community Magento Community
Magento Community
Magento Community
 
manhood
Jr. Member
 
Total Posts:  4
Joined:  2009-06-01
 

Bump, anyone can help us with this ? I want to get custom attribute for the invoice as well.

 
Magento Community Magento Community
Magento Community
Magento Community
 
jazkat
Sr. Member
 
Total Posts:  154
Joined:  2009-07-09
 

if you have a custom attribute “product_custom_attribute” this would get it out

$productId $item->getProductId();
$_newProduct Mage::getModel('catalog/product')->load($productId);  
if (
$_newProduct->getProductCustomAttribute())  
    
$_productName =  $_newProduct->getProductCustomAttribute();

if attribute is a drop-down you use getAttributeText(’attribute’)

echo $_newProduct->getAttributeText('product_custom_attribute')

you can use this anywhere - not just in PDFs..

 
Magento Community Magento Community
Magento Community
Magento Community
 
MagePsycho
Moderator
 
Avatar
Total Posts:  1702
Joined:  2009-06-23
 
jazkat - 14 June 2010 10:23 PM

if you have a custom attribute “product_custom_attribute” this would get it out

$productId $item->getProductId();
$_newProduct Mage::getModel('catalog/product')->load($productId);  
if (
$_newProduct->getProductCustomAttribute())  
    
$_productName =  $_newProduct->getProductCustomAttribute();

if attribute is a drop-down you use getAttributeText(’attribute’)
echo $_newProduct->getAttributeText('product_custom_attribute')

you can use this anywhere - not just in PDFs..

Let me summarize:

$_newProduct Mage::getModel('catalog/product')->load($productId);  
echo 
$_newProduct->getData('product_custom_attribute');
//or
echo $_newProduct->getProductCustomAttribute(); 
//or if attribute is a drop-down
echo $_newProduct->getAttributeText('product_custom_attribute')

am i right?
smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
vipuldadhich123
Jr. Member
 
Total Posts:  2
Joined:  2010-06-10
 

public function getcustomAttribute($attr = false)
{
$item = $this->getItem();
//$item = current($this->getOrder()->getAllItems() );
$prod = Mage::getModel( ‘catalog/product’ )
->load( $item->getProductId() );
foreach ($prod as $p){
$attribute = $prod->getResource()->getAttribute($attr);
$frontend = $af = $attribute->getFrontend();
$selectOptions = $af->getSelectOptions();
}
if($af->getSelectOptions())
{
foreach ($selectOptions as $options)
{
if($options[’value’]==$prod->getData($attr))
{
print_r($options[’label’]);
}
}
}
else echo $prod->getData($attr);
}
I have used this code for displaying the Custom.  This code works perfectly fine to show my custom attributes. But problem is this i am not able to use getAttributeText() to show my option values without using any iterations.

thanks in advance!
smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
Amasty
Mentor
 
Avatar
Total Posts:  3988
Joined:  2009-11-10
 

We are also glad to represent one more efficient tool for invoices - Custom Order Number extension, which enables you set any starting numbers and prefixes for all types of store documents such as invoices, orders, shipments, credit memos. Protect your private business info from your competitors and make your store more user-friendly.

For more details, user guide and live demo please follow the link http://amasty.com/custom-order-number.html

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top