Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7659849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:23:13+00:00 2026-05-31T13:23:13+00:00

How to get Order No. at event sales_order_place_after using event-observer model? I want to

  • 0

How to get Order No. at event sales_order_place_after using event-observer model?

I want to get Order No. as soon as order is placed by customer.

I want to pass that order no. to another external php file & include that php file in the Observer.php? How Can I do that?

I am trying to include external php file in Magento but I am unable to do that.

Observer.php:

<?php

 include("connection/Final/Function1.php");     
class Sample_Event_Model_Observer {

    public function Mytestmethod($observer) {

        $event = $observer->getEvent();  //Fetches the current event
        $eventmsg = "Current Event Triggered : <I>" . $event->getName() . "</I>";
        echo Mage::getSingleton('checkout/session')->addSuccess($eventmsg);

    $Id = $observer->getEvent()->getOrder()->getId();   
    $incrementid = $observer->getEvent()->getOrder()->getIncrementId();

    $ordermsg1 = "Current order Id : <I>" . $Id . "</I>";
        echo Mage::getSingleton('checkout/session')->addSuccess($ordermsg1);
    $ordermsg2 = "Current increment Id : <I>" . $incrementid . "</I>";
        echo Mage::getSingleton('checkout/session')->addSuccess($ordermsg2);

    $p = new testDatabase(); 
        $p -> setId($incrementid);
        $p -> dbConnect();
      }
}
?>  

Function1.php:

<?php 
class testDatabase 
{ 
    public function setId($getId)
    {
        $incrementid=$getId;
        echo $incrementid;
    }

    public function dbConnect()
     {  
            $db_name = "magento";
                $con = mysql_connect("localhost", "magento", "password");

        If (!$con)
        {
            die('Could not connect: ' . mysql_error());
        }
            $seldb = mysql_select_db($db_name, $con);
        If ($seldb) 
        {
            echo "Database Found ";
            $query = "INSERT INTO sample(id) VALUES($incrementid)" ;
            $result = mysql_query($query);
            print "id is added to the database"; 
            mysql_close($seldb);
        }
        else 
        {
            echo "Database NOT Found ";
        } 
     }
}

How can I access variable $incrementid in Function1.php? My problem is I am unable to access $incrementid as it is unable to insert in my sample table.

I have caught sales_order_place_after event. So that once customer press PLACE ORDER, I can include Function1.php & it will take increment/order id & I can able to access Functions in it that will do needful job.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:23:14+00:00Added an answer on May 31, 2026 at 1:23 pm

    You can get this from event

    $observer->getEvent()->getOrder()->getId() 
    
    $observer->getEvent()->getOrder()->getIncrementId() 
    

    what’s the point of including external files 🙂 you can load any model by

    Mage::getModel('your/extension_model')

    or if you are doing spaghetti like your question indicates then use require('path/to/file') and remember that this is a big nono.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing an observer for the sales_order_invoice_register event, I'd like to get the invoice
I'm attempting to get order data from a Yahoo store. I'm using the docs
I am using saxparser in order to get xml tag contents from file. All
I was given the following pseudo code in order to get the form that
I want to do some post processing on an order, made using admin panel.
I'm trying to get my order number on the event sales_order_payment_pay But somehow I
In cake php is how we can get order of query result according to
I get The ORDER BY clause is invalid in views, inline functions, derived tables,
How to get latest order No. from onepageController.php in checkout module in Magento? Or
In order to get my setup a bit closer to one click deployment, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.