I have added one customer address custom attribute. it is showing in the customer address form as a dropdown field. Now I want to show that as a column in customer address grid in admin with value.
I have added this code:
<column name="addresstype" class="xxx\xxx\Customer\Ui\Component\Listing\Address\Column\Addresstype" sortOrder="95">
<settings>
<filter>text</filter>
<label translate="true">addresstype</label>
<editor>
<editorType>text</editorType>
</editor>
</settings>
</column>
The column is added but the value is not showing in this. how to get the value which was set in form? I tried in the following way, but getting an error:
xxx/xxx/Customer/Ui/Component/Listing/Address/Column/Addresstype.php
public function prepareDataSource(array $dataSource): array
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as &$item) {
if ($item['addresstype'] == 1) {
$item['addresstype'] = 'Yes';
} else {
$item['addresstype'] = 'No';
}
}
}
return $dataSource;
}
But i ma getting error :
Undefined index: addresstype in /var/www/html/zest-anchor/app/code/Zest/Integration/Customer/Ui/Component/Listing/Address/Column/Addresstype.php on line 75 {"exception":"[object] (Exception(code: 0): Notice: Undefined index: addresstype in /var/www/html/zest-anchor/app/code/Zest/Integration/Customer/Ui/Component/Listing/Address/Column/Addresstype.php on line 75 at /var/www/html/zest-anchor/vendor/magento/framework/App/ErrorHandler.php:61)"} []