Skip to content

Commit

Permalink
Merge pull request #87 from CodistoConnect/mja-trim-customer-name
Browse files Browse the repository at this point in the history
used the desired pattern to trim the magento customer name
  • Loading branch information
jlivas authored Oct 20, 2022
2 parents 2fb19f2 + c71ce59 commit 6eb8331
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Controller/Index/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -1819,11 +1819,15 @@ private function _processCustomerData(
$customerGroupId = $koganGroup->getId();
}

$regexPattern = '/(?:[^\p{L}\p{M}\,\-\_\.\'’`\s\d]){1,255}+/u';
$matchedFirstName = preg_replace($regexPattern, '', (string)$addressBilling['firstname']);
$matchedLastName = preg_replace($regexPattern, '', (string)$addressBilling['lastname']);

$customer->setWebsiteId($websiteId);
$customer->setStoreId($store->getId());
$customer->setEmail($email);
$customer->setFirstname((string)$addressBilling['firstname']);
$customer->setLastname((string)$addressBilling['lastname']);
$customer->setFirstname($matchedFirstName);
$customer->setLastname($matchedLastName);
$customer->setPassword((string)sha1(uniqid()));
if ($customerGroupId) {
$customer->setGroupId($customerGroupId);
Expand Down

0 comments on commit 6eb8331

Please sign in to comment.