Magento – Export last 3 months shipment information

Recently I was supposed to export shipping carrier, order number, shipment number and associated customer info of an order. Here goes the code:

SELECT orders.increment_id, grid.increment_id, grid.created_at, address.firstname, address.lastname, address.email, track.track_number, title-- prior to 1.6 `track_number` should be `number`
FROM sales_flat_order AS orders
JOIN sales_flat_order_address AS address ON address.parent_id = orders.entity_id
JOIN sales_flat_shipment_grid AS grid ON grid.order_increment_id = orders.increment_id
JOIN sales_flat_shipment_track AS track ON track.order_id = orders.entity_id
WHERE address.address_type =  'shipping' and grid.created_at >= '2015-04-10'

Modify it according to your need and export the sheet.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s