Skip to content
This repository has been archived by the owner on Mar 9, 2023. It is now read-only.

Commit

Permalink
Merge pull request #18 from mageplaza/2.4-develop
Browse files Browse the repository at this point in the history
2.4 develop
  • Loading branch information
Shinichi69 authored Dec 28, 2021
2 parents 83f9169 + b6d8825 commit d3925c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 7 additions & 9 deletions Ui/Component/Listing/Columns/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@

namespace Mageplaza\LoginAsCustomer\Ui\Component\Listing\Columns;

use Exception;
use Magento\Customer\Model\ResourceModel\CustomerRepository;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Ui\Component\Listing\Columns\Column;
Expand Down Expand Up @@ -64,22 +63,21 @@ public function __construct(
* @param array $dataSource
*
* @return array
* @throws LocalizedException
* @throws NoSuchEntityException
*/
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as &$item) {
$customerId = $item['customer_id'];

$customer = $this->customerRepository->getById($customerId);
if ($customer && $customer->getId()) {
try {
$customer = $this->customerRepository->getById($customerId);
$item['customer_id'] = $customer->getFirstname() . ' ' .
$customer->getLastname() . ' <' . $customer->getEmail() . '>';
} else {
$item['customer_id'] = $item['customer_name'] . ' <' . $item['customer_email'] . '>';
} catch (Exception $e) {
$item['customer_id'] = $item['customer_name'] . ' <' . $item['customer_email']
. '> Note: Customer\'s account has been deleted.';
}

}
}

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"mageplaza/module-core": "^1.4.5"
},
"type": "magento2-module",
"version": "4.0.2",
"version": "4.0.3",
"license": "proprietary",
"authors": [
{
Expand Down

0 comments on commit d3925c2

Please sign in to comment.