Press "Enter" to skip to content

Month: June 2012

Extracting orders from Magento

We’re just experimenting with TrustPilot at the moment, but we needed to be able to import the customer name, order id and customer email address from our Magento shopping cart system into their system for population. Here’s the simple MySQL query we used to extract these details of all completed orders (i.e. not pending/processing ones) placed in the last two months:

SELECT
sales_flat_order.increment_id,
CONCAT(sales_flat_order.customer_firstname,' ',sales_flat_order.customer_lastname),
sales_flat_order.customer_email
FROM sales_flat_order
WHERE
sales_flat_order.state='complete' AND
sales_flat_order.created_at>(CURDATE()-INTERVAL 2 MONTH)