How to Edit Packing Slips in Magento?

The default packing slip that comes in Magento is brief. However there are certain methods that can be used to make packing slips elaborate and attractive. Here is how it can be done.

For editing the packing slips in Magento, we need to override the files in model and controller folder.

1.Access the config.xml file from app\code\local\Namespace\Modulename\etc\ config.xml and use the below code.
For Model Files:


For controllers Files:

</Namespace_ModuleName before=”Mage_Adminhtml”>Namespace_ModuleName_Adminhtml</Namespace_ModuleName>

Packing Slip

Then, we will have to override the OrderController.php file, which can be accessed from the below path

Read: How To Add Or Edit Top Links Sections In Magento

Frontend controller:

2. Now you will have to create a controller file called filename.php. This file should be created in

Here write pdfshipAction() and call the getPdf() function.

public function pdfshipAction() {
//This is not an increment ID. It is just an order id.
$orderId = $this->getRequest()->getParam(‘order_id’);
$flag = false;
if (!empty($orderId)) {
$shipments = Mage::getResourceModel(‘sales/order_shipment_collection’)
if ($shipments->getSize()) {
$flag = true;
if (!isset($pdf)){
$pdf = Mage::getModel(‘modulename/order_pdf_shipment’)->getPdf($shipments);
} else {
$pages = Mage::getModel(‘modulename/order_pdf_shipment’)->getPdf($shipments);
$pdf->pages = array_merge ($pdf->pages, $pages->pages);
if ($flag) {
return $this->_prepareDownloadResponse(
‘packingslip’.Mage::getSingleton(‘core/date’)->date(‘Y-m-d_H-i-s’).’.pdf’, $pdf->render(),
} else {
Mage::getSingleton(‘core/session’)->addError($this->__(‘There are no printable documents related to selected orders.’));
$shipmentId = $this->getRequest()->getParam(‘shipmentId’);
if (!empty($shipmentId)) {
$shipment = Mage::getModel(‘sales/order_shipment’)->load($shipmentId);
$shipmentData = $shipment->getData();
if (!empty($shipmentData)) {
$pdf = Mage::getModel(‘sales/order_pdf_shipment’)->getPdf(array($shipment));
$fileName = ‘-PackingSlip.pdf’;
$PakingSlip = date(“d-m-Y”).$fileName;
return $this->_prepareDownloadResponse($PakingSlip, $pdf->render(),’application/pdf’);
}else {
Mage::getSingleton(‘core/session’)->addError($this->__(‘There are no printable documents related to selected orders.’));
Mage::getSingleton(‘core/session’)->addError($this->__(‘At least one order must be selected’));

Admin controller:

Create an OrderController.php file in app\code\local\Namespace\ModuleName\controllers\Adminhtml\Sales\OrderController.php.

Here change the order_pdf_shipment Module name to your Module name.

require_once ‘Mage/Adminhtml/controllers/Sales/OrderController.php’;
class Namespace_Modulename_Adminhtml_Sales_OrderController extends Mage_Adminhtml_Controller_Action {
public function pdfshipmentsAction(){
For a better readability the remaining code has not been shown.
$pdf = Mage::getModel(‘ModuleName/order_pdf_shipment’)->getPdf($shipments);
} }

3. Now access the Abstract.php file from the path below: app\code\local\Namespace\Modulename\Model\Order\Pdf\Abstract.php and edit the insertOrder() function as

protected function insertOrder(&$page, $obj, $putOrderId = true)
Here you need to write the syntax for giving details such as the shipping address, billing address, payment methods and lot more.

4. Then access the Shipment.php file from

In the getPdf() function you should mention the details that you want to display in the packing slips.

public function getPdf($shipments = array()){
Here you need to write the syntax for editing the product details, subtotal, order total, etc.

To make your packing slip informative and attractive you can incorporate an appropriate function.

Given below is a function for sample purpose.

drawRectangle($x1, $y1, $x2, $y2,$fillType=Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE);
Class Zend_Pdf_Page ->provides a set of drawing primitives
SHAPE_DRAW_FILL_AND_STROKE ->fill rectangle and stroke (default))
Use drawText($text, $x, $y, $charEncoding = ‘ ‘); -> To write some text in the specified
Use setFont(Zend_Pdf_Resource_Font $font, $fontSize); -> To set Font
Use $color1 = new Zend_Pdf_Color_Html(‘#3366FF’); -> To set color

Finally to print the packing slip
Click Sale->order ->Select any order (the order should have been completed) ->Select Print packing slips in Action.

By implementing the above procedure you can edit the Magento packing slips successfully. In case you face any problems while editing the Magento packing slips, get in touch with us.

Realated Posts

2 thoughts on “How to Edit Packing Slips in Magento?

  1. Ashish Nayyar

    Great write-up, exactly to the point and help create packing slips in few minutes.

    • ramanathan

      Hi Ashish,

      It’s great to hear from you. Also check out other technical stuffs too.


Leave a Reply

Your email address will not be published. Required fields are marked *



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code lang=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" extra="">