Skip to content

Instantly share code, notes, and snippets.

@mladenilic
Last active June 25, 2018 14:08
Show Gist options
  • Save mladenilic/0c6b263efebc50a346648d9da9516e47 to your computer and use it in GitHub Desktop.
Save mladenilic/0c6b263efebc50a346648d9da9516e47 to your computer and use it in GitHub Desktop.
Scramble emails in test Magento DB
-- mladen@stuntcoders.com -> mladen@example.com
UPDATE `customer_entity` SET `email` = REPLACE(`email`, SUBSTRING(`email`, INSTR(`email`, '@') + 1), 'example.com');
UPDATE `sales_flat_quote_address` SET `email` = REPLACE(`email`, SUBSTRING(`email`, INSTR(`email`, '@') + 1), 'example.com');
UPDATE `sales_flat_order_address` SET `email` = REPLACE(`email`, SUBSTRING(`email`, INSTR(`email`, '@') + 1), 'example.com');
@ysfks
Copy link

ysfks commented Jun 25, 2018

In case if you get a Duplicate Entry error, you can use it like
UPDATE customer_entitySETemail = REPLACE(email, SUBSTRING(email, INSTR(email, '@') + 1), CONCAT('example', entity_id, '.com'));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment