I found how to create an invoice programmatically but nothing about to create a shipment pdf.
So far I can create the shipment for items but I have no clue how create the pdf.


If you have already shipment of order then you can create shipment pdf. using sale pdf shipment model ,pdf has been created.


if ($shipment = Mage::getModel('sales/order_shipment')->load($shipmentId)) {
$pdf = Mage::getModel('sales/order_pdf_shipment')->getPdf(array($shipment));

Create Shipment first:

You need to create ship first without shipment create pdf is not created.

Try below


foreach($order->getAllItems() as $eachOrderItem){

     $Itemqty = $eachOrderItem->getQtyOrdered()
            - $eachOrderItem->getQtyShipped()
            - $eachOrderItem->getQtyRefunded()
            - $eachOrderItem->getQtyCanceled();


$comment="test Shipment";

if ($order->canShip()) {
         /* @var $shipment Mage_Sales_Model_Order_Shipment */
        /* prepare to create shipment */
     $shipment = $order->prepareShipment($qty);
      if ($shipment) {
          $shipment->addComment($comment, $email && $includeComment);
            try {
                $transactionSave = Mage::getModel('core/resource_transaction')
                $shipment->sendEmail($email, ($includeComment ? $comment : ''));
            } catch (Mage_Core_Exception $e) {



See more about:Programmatically create Shipment of a new order in magento

| improve this answer | |
  • Ok, I will try it. And this is also possible with shipment_items? I mean single items from the table "sales_flat_shipment_item" although there are related items which has the same parent_id. – Timo.Klement Apr 1 '15 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.