Arjun
9/5/2019 - 1:50 PM

Create Invoice Programmatically

if (isset($_GET['debug'])) {
    $order = Mage::getModel("sales/order")->load('12898');
    $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
    $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
    $invoice->register();
    $transactionSave = Mage::getModel('core/resource_transaction')
        ->addObject($invoice)
        ->addObject($invoice->getOrder());
    
    $transactionSave->save();
}