diff --git a/Controller/Adminhtml/Edit/Index.php b/Controller/Adminhtml/Edit/Index.php
index d4aff6f..fc38103 100755
--- a/Controller/Adminhtml/Edit/Index.php
+++ b/Controller/Adminhtml/Edit/Index.php
@@ -10,6 +10,7 @@
use Exception;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
+use Magento\Backend\Model\Auth\Session;
use Magento\Customer\Api\AccountManagementInterface;
use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Framework\Controller\Result\Json;
@@ -49,6 +50,10 @@ class Index extends Action
* @var EmailAddress
*/
private $emailAddressValidator;
+ /**
+ * @var Session
+ */
+ private $authSession;
/**
* Index constructor.
@@ -59,6 +64,7 @@ class Index extends Action
* @param JsonFactory $resultJsonFactory
* @param CustomerRepositoryInterface $customerRepository
* @param EmailAddress $emailAddressValidator
+ * @param Session $authSession
*/
public function __construct(
Context $context,
@@ -67,7 +73,8 @@ public function __construct(
OrderCustomerManagementInterface $orderCustomerService,
JsonFactory $resultJsonFactory,
CustomerRepositoryInterface $customerRepository,
- EmailAddress $emailAddressValidator
+ EmailAddress $emailAddressValidator,
+ Session $authSession
) {
parent::__construct($context);
@@ -77,6 +84,7 @@ public function __construct(
$this->accountManagement = $accountManagement;
$this->customerRepository = $customerRepository;
$this->emailAddressValidator = $emailAddressValidator;
+ $this->authSession = $authSession;
}
/**
@@ -119,6 +127,14 @@ public function execute()
/** @var $order OrderInterface */
$order = $this->orderRepository->get($orderId);
if ($order->getEntityId() && $order->getCustomerEmail() == $oldEmailAddress) {
+ $comment = sprintf(
+ __("Order email address change from %s to %s by %s"),
+ $oldEmailAddress,
+ $emailAddress,
+ $this->authSession->getUser()->getUserName()
+ );
+
+ $order->addStatusHistoryComment($comment);
$order->setCustomerEmail($emailAddress);
$this->orderRepository->save($order);
}
diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
index 837ff61..a28fe5b 100755
--- a/etc/adminhtml/system.xml
+++ b/etc/adminhtml/system.xml
@@ -20,7 +20,7 @@
Copyright © 2018 www.magepal.com / support@magepal.com
+ Copyright © 2019 www.magepal.com / support@magepal.com
Discover other must have extensions at www.magepal.com. Thanks for choosing MagePal Extensions.
]]>
diff --git a/i18n/en_US.csv b/i18n/en_US.csv
new file mode 100644
index 0000000..a8f12fd
--- /dev/null
+++ b/i18n/en_US.csv
@@ -0,0 +1,9 @@
+"Module Version","Module Version"
+"Composer Version","Composer Version"
+"CUSTOM SHIPPING RATE","CUSTOM SHIPPING RATE"
+"Enable","Enable"
+"Invalid order id.","Invalid order id."
+"Invalid Email address.","Invalid Email address."
+"Order email address change from %s to %s by %s","Order email address change from %s to %s by %s"
+"Email address successfully changed.","Email address successfully changed."
+"Automatically update customer record email address","Automatically update customer record email address"
\ No newline at end of file