Skip to content

Commit dee9bd9

Browse files
Add fallback for no such entity with customerId
1 parent ae217d9 commit dee9bd9

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/Ui/Component/Listing/Column/CustomerInfo.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,18 @@ public function __construct(
2121
parent::__construct($context, $uiComponentFactory, $components, $data);
2222
}
2323

24-
public function prepareDataSource(array $dataSource)
24+
public function prepareDataSource(array $dataSource): array
2525
{
2626
if (isset($dataSource['data']['items'])) {
2727
foreach ($dataSource['data']['items'] as &$item) {
28-
$customerId = $item['customer_id'];
29-
$customer = $this->customerRepository->getById($customerId);
30-
$customerName = $customer->getFirstname() . ' ' . $customer->getLastname();
31-
$item[$this->getData('name')] = $customerName . ' (' . $customerId . ')';
28+
try {
29+
$customerId = $item['customer_id'];
30+
$customer = $this->customerRepository->getById($customerId);
31+
$customerName = $customer->getFirstname() . ' ' . $customer->getLastname();
32+
$item[$this->getData('name')] = $customerName . ' (' . $customerId . ')';
33+
} catch (\Exception $e) {
34+
$item[$this->getData('name')] = '-';
35+
}
3236
}
3337
}
3438

0 commit comments

Comments
 (0)