Magento: find orders containing a product

Magento: find orders containing a product

July 3, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento: find orders containing a product

Finding Orders Containing a Specific Product in Magento

As a senior developer specializing in e-commerce platforms like Magento, I often receive queries from businesses looking to optimize their order management processes. One common question is how to identify all the orders that contain a particular product within the Magento system.

The Challenge: Locating Specific Orders by Product

The default administration panel provides several useful reports, but it falls short when you need to pinpoint which specific orders include a given product. While the “Products Ordered” report under Reports > Products offers insights into the quantity of each product sold and its respective order count, it doesn’t directly point to the individual orders.

A Step-by-Step Solution: Using Magento’s API

To achieve this, we can leverage Magento’s SOAP or REST APIs to query the database for the required information. Here’s a simplified guide using PHP and the Magento SOAP API:

  1. First, create a new SoapClient instance pointing to your Magento site’s SOAP API endpoint.
$client = new SoapClient('http://your_magento_site.com/index.php/api/soap?wsdl');
  1. Authenticate with your admin credentials and load the catalog product details.
$sessionId = $client->login('your_username', 'your_password');
$products = $client->catalogProductList($sessionId);
  1. Loop through the products to find the one you’re looking for, then retrieve its order IDs using the sales_order_grid_collection method.
foreach ($products as $product) {
    if ($product['sku'] === 'SKU_12345') { 
        // Found the product!
        $orderIds = $client->salesOrderGridCollection($sessionId, array('searchCriteria' => array('filterGroups' => array(array(
            'filters' => array(array('field' => 'sku', 'value' => 'SKU_12345'))
        )))));
    }
}

Enhancing the Solution: Creating a Custom Module

While the API solution works, it requires programming knowledge and isn’t directly accessible from the admin panel. For a more user-friendly approach within the Magento ecosystem itself, consider creating a custom module.

This would involve developing an extension that provides a new menu item under Sales > Orders to search for orders containing a specified product by SKU or ID. The module would use Magento’s core models and collections to efficiently retrieve and display the relevant order data.

The Benefits of Using Custom Modules

Building a custom module offers several advantages:

  • User-friendly interface: It provides an intuitive way for non-technical users within your team to find orders by product directly from the admin panel.
  • Performance optimization: By leveraging Magento’s built-in models and collections, you can create a solution that respects the platform’s architecture and ensures optimal performance.
  • Maintainability: Custom modules can be easily updated or extended as your business needs evolve.

Conclusion: Empowering Your Team with Streamlined Order Management

In summary, finding orders containing a specific product in Magento requires a combination of understanding the platform’s API functionality and possibly developing custom solutions to meet your precise requirements. By following the guidelines outlined here and considering a custom module for enhanced usability, you can effectively optimize your order management processes and boost operational efficiency.

Remember, when it comes to extending Magento with custom solutions or integrating third-party systems, always consult our dedicated Magento development services at Laravel Company. Our team of experienced Magento developers is ready to help you unlock the full potential of your e-commerce platform.

Catalog Database Performance API

Our network