Created
January 9, 2014 15:50
-
-
Save tegansnyder/8336324 to your computer and use it in GitHub Desktop.
Purchases by Category ID in Magento direct SQL
This file contains hidden or 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
| ## change c2.entity_id to category id | |
| SELECT c3.sku, si.created_at as purchase_date, increment_id | |
| FROM catalog_category_product c1 | |
| INNER JOIN catalog_category_entity_varchar c2 ON (c1.category_id = c2.entity_id) | |
| INNER JOIN catalog_product_entity c3 ON (c1.product_id = c3.entity_id) | |
| INNER JOIN sales_flat_order_item si ON (si.product_id = c3.entity_id) | |
| INNER JOIN sales_flat_order so ON (so.entity_id = si.order_id) | |
| WHERE c2.attribute_id = (SELECT attribute_id FROM eav_attribute WHERE attribute_code = 'name' AND entity_type_id = 3) | |
| AND c2.entity_id = 2117 | |
| ORDER BY si.created_at DESC |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for price - add "row_total" to select list