diff --git a/Ui/Component/Listing/Columns/Customer.php b/Ui/Component/Listing/Columns/Customer.php index 56d4dfa..8b49f6d 100644 --- a/Ui/Component/Listing/Columns/Customer.php +++ b/Ui/Component/Listing/Columns/Customer.php @@ -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; @@ -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.'; } + } } diff --git a/composer.json b/composer.json index 7333f8f..d171968 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "mageplaza/module-core": "^1.4.5" }, "type": "magento2-module", - "version": "4.0.2", + "version": "4.0.3", "license": "proprietary", "authors": [ {