Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added param for list domains for which email addresses will be left untouched #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ Assigns the order #10000000001 to customer ID 10.
Anonymize customer email addresses across a bunch of tables: order, order address, newsletter, quotes,
newsletter subscriber.

$ mr customer:anon
Optionally you can pass a comma separated list of domain for which email addresses will be left untouched.

$ mr customer:anon [--whitelist="example.com,dummy.net,..."]

### Core file diff ###

Expand Down
9 changes: 9 additions & 0 deletions src/KJ/Magento/Command/Customer/AnonymizeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ protected function configure()
{
$this
->setName('customer:anon')
->addOption('whitelist', null, InputOption::VALUE_OPTIONAL, "A comma separated list of domains for which email addresses will be left untouched")
->setDescription('Strip all email addresses from customer tables.')
;
}
Expand Down Expand Up @@ -55,6 +56,14 @@ protected function _anonymizeTable($table, $emailColumn)
"concat('test+',SUBSTRING(SHA1(CONCAT($emailColumn,'$salt')) FROM 1 FOR 10),'@example.com') " .
"where $emailColumn not like 'test+%;'";

if ($this->_input->getOption('whitelist')) {
$whitelistDomains = explode(',', $this->_input->getOption('whitelist'));

foreach ($whitelistDomains as $domain) {
$query .= " AND $emailColumn not like '%@" . $domain . "'";
}
}

$connection->query($query);

return $this;
Expand Down