Skip to content

Commit

Permalink
Add translation and add order comment
Browse files Browse the repository at this point in the history
  • Loading branch information
srenon committed Apr 11, 2019
1 parent c344bb2 commit 3096508
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
18 changes: 17 additions & 1 deletion Controller/Adminhtml/Edit/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -49,6 +50,10 @@ class Index extends Action
* @var EmailAddress
*/
private $emailAddressValidator;
/**
* @var Session
*/
private $authSession;

/**
* Index constructor.
Expand All @@ -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,
Expand All @@ -67,7 +73,8 @@ public function __construct(
OrderCustomerManagementInterface $orderCustomerService,
JsonFactory $resultJsonFactory,
CustomerRepositoryInterface $customerRepository,
EmailAddress $emailAddressValidator
EmailAddress $emailAddressValidator,
Session $authSession
) {
parent::__construct($context);

Expand All @@ -77,6 +84,7 @@ public function __construct(
$this->accountManagement = $accountManagement;
$this->customerRepository = $customerRepository;
$this->emailAddressValidator = $emailAddressValidator;
$this->authSession = $authSession;
}

/**
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<label>Edit Order Email</label>
<comment>
<![CDATA[
<strong>Copyright © 2018 <a href="http://bit.ly/MPEXSMTP" target="_blank">www.magepal.com</a> / <a href="mailto:[email protected]">[email protected]</a></strong><br />
<strong>Copyright © 2019 <a href="http://bit.ly/MPEXSMTP" target="_blank">www.magepal.com</a> / <a href="mailto:[email protected]">[email protected]</a></strong><br />
Discover other must have extensions at <a href="https://www.magepal.com" target="_blank">www.magepal.com</a>. Thanks for choosing MagePal Extensions.<br/><br/>
<hr style="border-top: 1px solid #e3e3e3" />
]]>
Expand Down
9 changes: 9 additions & 0 deletions i18n/en_US.csv
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 3096508

Please sign in to comment.