Created
November 26, 2012 16:08
-
-
Save heathdutton/4149003 to your computer and use it in GitHub Desktop.
Magento Custom - Get a list of customers/contracts that are affected by forceful product deletion
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 DISTINCT | |
customer_entity.email as Email, | |
enterprise_giftregistry_entity.tui_holiday_contract_id as Contract, | |
enterprise_giftregistry_entity.tui_holiday_departure_date as Departure | |
FROM | |
enterprise_giftregistry_item, | |
enterprise_giftregistry_entity, | |
customer_entity | |
WHERE | |
# Only do this for holidays that have not yet departed | |
enterprise_giftregistry_entity.tui_holiday_departure_date > NOW() AND | |
# Product no longer exists because it was forcibly deleted | |
enterprise_giftregistry_item.product_id NOT IN | |
(SELECT entity_id FROM catalog_product_entity) AND | |
# Product has not yet been purchased (If the item is already paid for we are not removing it) | |
(enterprise_giftregistry_item.qty_fulfilled IS NULL OR | |
enterprise_giftregistry_item.qty_fulfilled < enterprise_giftregistry_item.qty) AND | |
# Get the associated giftregistry entity | |
enterprise_giftregistry_entity.entity_id = enterprise_giftregistry_item.entity_id AND | |
# Get the associated user entity | |
enterprise_giftregistry_entity.customer_id = customer_entity.entity_id; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment