Add this to Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php, replace ATTRNAME as appropriate.
public function draw() { ... $product = Mage::getModel('catalog/product')->loadByAttribute('sku', $this->getSku($item), array('ATTRNAME')); if ($product) { $lines[0][] = array( 'text' => Mage::helper('core/string')->str_split($product->getData('ATTRNAME'), 15), 'feed' => 305 ); }
Then add this to Mage/Sales/Model/Order/Pdf/Invoice.php, replace ATTR_TITLE as appropriate and OFFSET with the left offset.
/* Add table head */ ... $page->drawText(Mage::helper('sales')->__('ATTR_TITLE'), OFFSET, $this->y, 'UTF-8');
if (!empty($settings['table_header'])) { ... $page->drawText(Mage::helper('sales')->__('ATTR_TITLE'), OFFSET, $this->y, 'UTF-8');
There is no definitive solution as you need to change a few other details to limit column widths in other areas depending on where you are trying to put your values (ie. description is usually made narrower and forced to line-wrap).
Referenced from: http://www.magentocommerce.com/boards/viewthread/18142/P15/#t201627
Brian
25 Jan. 2010
How would I add the customer’s email address to the PDF invoice?
I noticed that if I add this code:
$customer = Mage::getModel(‘customer/customer’)->load($order->getData(‘customer_id’));
$email = $customer->getData(‘email’);
$page->drawText($email, 35, 735, ‘UTF-8′);
—- that it will add the customer’s email, but only if they have an account.
How do I add the customer’s email to the PDF invoice if they checked out as a GUEST?
thankx
Brian
25 Jan. 2010
Answered by own question:
In Order/PDF/Abstract.php:
After the code:
foreach ($billingAddress as $value){
if ($value!==”) {
$page->drawText(strip_tags(ltrim($value)), 35, $this->y, ‘UTF-8′);
$this->y -=10;
}
}
I added this code:
/* email goes here */
$page->drawText(Mage::helper(‘sales’)->__(”).$order->getCustomerEmail(), 35, $this->y, ‘UTF-8′);
Hope that helps anyone else.
Evan S
23 Mar. 2010
The code provided by Brian works perfect, but be careful about getting the punctuation right when you’re implementing it. When I just cop/pasted this, it used the wrong style of quote marks and broke it.
You want to use:
Tegan Snyder
6 May. 2010
I appreciate you posting this. I was able to successfully modify the packslips to include the manufacture cost field.
Thanks,
Tegan
Edwin
31 Mar. 2011
So I get the title in my packing slip, but not the attributes. See: http://screencast.com/t/icfzThfW
The attribute name is ‘afmetingen’.
Here’s how I implement the code:
Code 1: http://screencast.com/t/bWC6afUMKAu8
Code 2: http://screencast.com/t/yDXxbxLsV99
Code 3: http://screencast.com/t/Fr7B6rABEPSU
Any tips how I solve this?
Edwin
31 Mar. 2011
My bad. I made a mistake with the attribute name. It works now
Mike
13 May. 2011
Edwin,
What was your mistake? Is this case sensitive? I cannot get the attribute field to populate, but I can the table header. Any help would be appreciated.
My Code:
Invoice.php
if (!empty($settings['table_header'])) {
$this->_setFontRegular($page);
$page->setFillColor(new Zend_Pdf_Color_RGB(0.93, 0.92, 0.92));
$page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
$page->setLineWidth(0.5);
$page->drawRectangle(25, $this->y, 570, $this->y-15);
$this->y -=10;
$page->setFillColor(new Zend_Pdf_Color_RGB(0.4, 0.4, 0.4));
$page->drawText(Mage::helper(‘sales’)->__(‘Product’), 35, $this->y, ‘UTF-8′);
$page->drawText(Mage::helper(‘sales’)->__(‘SKU’), 255, $this->y, ‘UTF-8′);
$page->drawText(Mage::helper(‘sales’)->__(‘Manufacturer’), 300, $this->y, ‘UTF-8′);
$page->drawText(Mage::helper(‘sales’)->__(‘Price’), 380, $this->y, ‘UTF-8′);
$page->drawText(Mage::helper(‘sales’)->__(‘Qty’), 430, $this->y, ‘UTF-8′);
$page->drawText(Mage::helper(‘sales’)->__(‘Tax’), 480, $this->y, ‘UTF-8′);
$page->drawText(Mage::helper(‘sales’)->__(‘Subtotal’), 535, $this->y, ‘UTF-8′);
$page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
$this->y -=20;