Execute PHP after new Order in Magento

Execute PHP after new Order in Magento

July 19, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Execute PHP after new Order in Magento

Executing PHP after New Order in Magento

As a senior developer working extensively with e-commerce platforms like Magento, I often encounter scenarios where clients need to trigger external APIs or processes when a new order is placed. In your case, you want to notify the Solve360 CRM and create an event to fulfill the order via its API.

To achieve this, there are several approaches we can take in Magento 1.x:

Approach 1: Use Observer Events

Magento has built-in observer events that fire when specific actions occur, including when a new order is placed. The sales_order_place_after event is perfect for your use case as it triggers after an order is successfully placed and captured.

Here’s how to implement this:

  1. Create a custom module in your Magento root directory (e.g., app/code/local/Namespace/Module/etc/config.xml):
<config>
  <modules>
    <Namespace_Module>
      <version>1.0.0</version>
    </Namespace_Module>
  </modules>
</config>
  1. Register the observer in etc/config.xml:
<global>
  <events>
    <sales_order_place_after>
      <observers>
        <namespace_module_observer>
          <type>singleton</type>
          <class>Namespace_Module_Model_Observer</class>
          <method>notifyCrmAboutNewOrder</method>
        </namespace_module_observer>
      </observers>
    </sales_order_place_after>
  </events>
</global>
  1. Create the observer in app/code/local/Namespace/Module/Model/Observer.php:
public function notifyCrmAboutNewOrder($observer) {
    $order = $observer->getEvent()->getOrder();
    // Your logic to send data to Solve360 CRM API goes here
}

Approach 2: Use Magento’s Built-in APIs

Magento provides SOAP and REST APIs that can be used to interact with the platform programmatically. You could create a custom API endpoint in your module to handle the order placement notification.

To learn more about building custom APIs in Magento, check out our guide on Creating Custom REST APIs at Laravel Company.

Conclusion

When deciding where to place your PHP code to notify the CRM after a new order is placed, I recommend using observer events. This approach is clean, follows Magento’s best practices, and keeps your logic separate from core files.

If you prefer more flexibility or need to handle additional data, the custom API endpoint approach could be more suitable. Both methods allow you to achieve your goal without modifying core files, reducing the risk of conflicts during updates.

Remember that when working with APIs, always ensure proper authentication, error handling, and logging practices are in place to maintain data integrity and security.

Feel free to explore our other Magento development resources at Laravel Company for more tips and best practices.

Magento 1 API Extensions Configuration

Our network