views:

33

answers:

3

I need to display an additonal custom attribute from a product on the Order Slip PDF so that our distributor can find the proper product id. We have 3 different types of SKUs being used; one is our own, the other is from our supplier and another is from the manufacturer.

Which part of Magento do I have to change in order to add the custom product attribute? Is there an extension that lets me do that or do I have to write some code?

A: 

I am not sure whether anyone has written any extensions for PDF formatting, most people seem to replace it entirely with a PDF they have written. This is because Magento's PDF writing is terribly written, and not really up for changes.

If you cannot find an extension to modify the existing PDFs, plan around it.

Hope that helps!

Thanks, Joe

Joseph Mastey
+1  A: 

Look in the file app/code/core/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php. That contains the part necessary for product output. Copy the file to a matching directory path but in app/code/local, this is a safe way to override and make edits. You should be able to see how the $lines array is used for positioning text.

Try inserting something like this either just before or just after the custom options.

// The quote item doesn't have any product attributes, it is only a quote!
$product = Mage::getModel('catalog/product')->load($item->getProductId());
// Use the actual product object to add a new line.
$lines[][] = array(
    'text' => Mage::helper('core')->__('Manufacturer SKU: ') . $product->getManufacturerSku(),
    'feed' => 35
);

Exactly where you insert and what you call the attribute is your choice of course.

clockworkgeek
Sounds a bit painful, but I guess I'll give it a go and see what happens :D
omouse
A: 

An additional idea - as Joseph suggested you might be able to plan around it...

Instead of an attribute you can create the extra data as a drop-down custom option, with only one possible value that is set to default. It will show on the product, cart, checkout, order, invoice pages and the PDF and the customer will not be able to deselect it.

clockworkgeek