-
-
Save trabulium/5583487 to your computer and use it in GitHub Desktop.
Customer Wishlist including lastname, price, sku
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 b.email, c.value AS name,d.value as lastname, a.updated_at, e.added_at, e.product_id, f.sku, f.name, f.price, SUM(h.qty_ordered) AS purchased | |
FROM `mage_wishlist` AS a | |
INNER JOIN mage_customer_entity AS b ON a.customer_id = b.entity_id | |
INNER JOIN mage_customer_entity_varchar AS c ON a.customer_id = c.entity_id AND c.attribute_id = (SELECT attribute_id FROM mage_eav_attribute WHERE attribute_code = 'firstname' AND entity_type_id = b.entity_type_id) | |
INNER JOIN mage_customer_entity_varchar AS d ON a.customer_id = d.entity_id AND d.attribute_id = (SELECT attribute_id FROM mage_eav_attribute WHERE attribute_code = 'lastname' AND entity_type_id = b.entity_type_id) | |
INNER JOIN mage_wishlist_item AS e ON a.wishlist_id = e.wishlist_id | |
INNER JOIN mage_catalog_product_flat_1 AS f ON e.product_id = f.entity_id | |
LEFT JOIN mage_sales_flat_order AS g ON g.customer_email = b.email | |
LEFT JOIN mage_sales_flat_order_item AS h ON (g.entity_id = h.order_id AND h.sku LIKE CONCAT(f.sku,'%') AND h.product_type = 'simple') | |
GROUP BY b.email, c.value, a.updated_at, e.added_at, e.product_id, f.name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment