0

I am using below code to create shipment programmatically.

$shipment = Mage::getModel('sales/service_order', $order)->prepareShipment($qty);
$shipment->register();
$shipment->sendEmail(true)->setEmailSent(true)->save();

But nothing is happening. No shipment is created in back-end and no error is reported.

1

I'm assuming your $qty and $order are correct. I don't think shipments can be created just doing a save(). Try this.

$shipment = Mage::getModel('sales/service_order', $order)
    ->prepareShipment($qty);
$shipment->register();

$shipment->getOrder()->setIsInProcess(true);
$transactionSave = Mage::getModel('core/resource_transaction')
    ->addObject($shipment)
    ->addObject($shipment->getOrder())
    ->save();

See Mage_Adminhtml_Sales_Order_ShipmentController::_saveShipment for the exact implementation details.

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.