1

I want order id in observe function but I am getting null I am using this code Observe.php

public function invoiceexport(Varien_Event_Observer $event=null){
    $_helper = Mage::helper('Nino_invoiceexport');
    $importStartDateTime = date('Y-m-d H:i:s');
    $orders = $event->getOrder();
    print_r($orders);
    die;
}

My config.xml is as :

<events>
    <sales_order_invoice_save_after>
         <observers>
             <Nino_invoiceexport_order_invoice_save_after>
                  <type>singleton</type>
                  <class>Nino_InvoiceExport_Model_Observer</class>
                  <method>invoiceexport</method>
              </Nino_invoiceexport_order_invoice_save_after>
          </observers>
     </sales_order_invoice_save_after>
</events>

1 Answer 1

3

You can get orderId by using this way,

    $invoice = $observer->getEvent()->getInvoice();
    $order = $invoice->getOrder();
    $orderId=$order->getId();
2
  • thanks Keyur one more things t want a customer id. how can i get this.
    – Piyush
    Nov 13, 2017 at 11:46
  • $order->getCustomerId() it will return if customer is exist in your webshop @Piyush
    – Keyur Shah
    Nov 13, 2017 at 12:40

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.