Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Magento 2 chcek for orders with more than one shipment or invoice
-- Orders with more than one shipment
SELECT orders.increment_id AS ordernummer, orders.created_at, count(*) as `Aantal verzendingen` FROM sales_shipment as shipments
LEFT JOIN sales_order AS orders ON orders.entity_id = shipments.order_id
GROUP BY shipments.order_id
HAVING `Aantal verzendingen` > 1
ORDER BY orders.created_at;
-- Orders with more than 1 invoice
SELECT orders.increment_id AS ordernummer, orders.created_at, count(*) as `Aantal facturen` FROM sales_invoice as invoices
LEFT JOIN sales_order AS orders ON orders.entity_id = invoices.order_id
GROUP BY invoices.order_id
HAVING `Aantal facturen` > 1
ORDER BY orders.created_at;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment