开发者

How do I modify the Magento Order Slip to show a custom product attribute?

开发者 https://www.devze.com 2023-01-21 18:00 出处:网络
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 ow

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 t开发者_StackOverflowhe 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?


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.


we have made an extension which covers all these things.

You can :

  • show multiple custom attributes, in multiple formats, and even filter them
  • output a highly-customised invoice, packing slip, or pick list
  • produce the PDFs no matter what the order status is

Check it out, it will honestly make your order processing much faster, and the 'final word' that the customer sees will leave them impressed and ordering again!

Magento Customised PDFS : Invoices, Packing Sheets, and PickLists


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号