Last active
March 8, 2023 11:15
-
-
Save hornofj/5b28ae2288e7cb1b24cf00c258f4e146 to your computer and use it in GitHub Desktop.
Simple order export from Magento 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT so.increment_id as 'id', | |
so.created_at AS 'date', | |
so.status, | |
ROUND(so.grand_total,2) AS 'total', | |
so.order_currency_code AS 'currency', | |
so.customer_email AS 'email', | |
so.shipping_description AS 'shipping', | |
sop.method AS 'payment', | |
soa.`firstname`, | |
soa.`lastname`, | |
soa.city, | |
soa.`street`, | |
soa.`postcode`, | |
soa.`country_id` AS 'country', | |
soa.`company`, soa.`telephone`, | |
GROUP_CONCAT(CONCAT(soi.name,' (',ROUND(soi.qty_ordered, 0),'x)') SEPARATOR '\n') AS 'items' | |
FROM sales_order so | |
JOIN sales_order_address soa ON soa.parent_id=so.`entity_id` | |
JOIN sales_order_payment sop ON sop.parent_id=so.entity_id | |
JOIN sales_order_item soi ON soi.order_id=so.entity_id | |
WHERE soa.`address_type`='shipping' | |
AND soi.`product_type`='simple' | |
GROUP BY soi.order_id | |
ORDER BY so.created_at DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment