If you're a Magento 2 developer, sooner or later you'll need to generate multiple orders — and doing it manually can be time-consuming and inefficient. That’s why programmatic order creation is often the preferred approach.
I built this Magento 2 order generator to meet the needs of the Amasty team and decided to share it with you. It also allows you to set the Magento 2 payment method programmatically, making the process even more streamlined.
If you're looking to test how custom data behaves within orders, consider pairing this tool with our Order Attributes for Magento 2 extension. It lets you add extra fields to the checkout and order view pages, helping you collect and manage all the data you need — ideal for advanced testing or enriching customer order data.
Note: Try out our same-titled extensions to export Magento 2/ Magento 1 orders with all the related data.
I created this generator to speed up order creation for testing and debugging purposes. Personally, I use it to verify how statistics behave, how our extensions handle large volumes of data, and for other specific development needs.
Creating Magento 2 Orders Programmatically
Magento 2 lets you create console extensions, and I chose this method because adding a user interface for this task would be unnecessary.
How to Install the Magento 2 Order Generator
You can install the order generator like any other console extension:
1. Copy the extension files to the default catalog.
2. Go to the console in the default catalog (double-check, as the console may point to another directory by default) and run the command:php bin/magento setup:upgrade
How to Run the M2 Order Generator + Bonus Feature: Generating Customers
After installing the extension, you can start generating orders. This Magento 2 order generator can also create customers — but only in combination with order generation. Standalone customer creation isn’t supported.
To generate orders and customers, use the command:php bin/magento amasty:create_orders 5 3
Here, 5 is the number of orders per customer, and 3 is the number of customers to generate orders for.
You can set your own numbers. If you omit the customer number, the tool will default to generating orders for a single customer.
Keep in mind that generating a large number of Magento 2 orders for one customer may take more time. This slowdown also occurs when manually creating many orders without a script, and we’re still investigating the root cause.
Magento 2 Order Generation Example
If you've set a high number of orders or customers (e.g., 200) and need to interrupt the process, use CTRL+C
— the standard Linux shortcut to stop a running command.
Example Output
Orders generated for Magento 2
Customers generated for M2
Each order includes relevant Magento 2 order comments to simulate real-world data and help with debugging or testing workflows that rely on customer communication history.
Here’s how the generated M2 customers look:
Fixing the Common Stock Issue
When generating many orders, you’ll likely run out of in-stock products quickly. To resolve this, run:php bin/magento amasty:update_product_qty 200
This command sets all products to have 200 items in stock, saving you time on restocking manually.
Adding More Settings
If you need more variety or want to configure specific order attributes — such as status, payment method, or Magento save order behavior — open:app/code/Amasty/Console/Console/Command/CreateOrdersCommand.php
You can customize parameters directly in this file.
$_shippingMethod – the shipping method ID. For example, you can find the shipping method ID in the Cart Price rules: visit the page of editing a rule, go to the conditions tab, add a new condition, choose the shipping method, right click on the corresponding option and look for the ID like so:
$_paymentMethod – the payment method ID. You can find it by following the same steps as in the previous point for a shipping method:
$_storeId – the store ID. You can find this ID in the browser address bar when you’re editing the corresponding store view:
$_emails – the customer emails array – in case you are willing to use some particular existing customers for order generation.
$_days – how old the order should be.
That's pretty much it!