I had deleted an invoice programmatically by using the following code:

$invoice = Mage::getModel('sales/order_invoice')->load(97);

Now I need Invoice Button to invoice again. I have done lot of Google but didn't got success.

Please Help Me

1 Answer 1


The issue in this case is that the order's state needs to be reset.

I had a similar issue where the invoice was deleted, but I could not create a new invoice.

I used this code on a test.php page to successfully reset the order's status manually. It does delete all invoices in the process just in case there is anything left over.

$order_id = 97;
$order = Mage::getModel("sales/order")->loadbyIncrementId($order_id);
$invoices = $order->getInvoiceCollection();
foreach ($invoices as $invoice){
$order->setState(Mage_Sales_Model_Order::STATE_NEW, true)->save();
  • 1
    use loadbyIncrementId if $order_id is something like '10000111' , if not just 'load'
    – Ansyori
    Jun 8, 2018 at 8:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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