I want to add a column for the customer-agent =>(my module) in order table
I add this in to app/code/Orienteed/CustomerAgent/view/adminhtml/ui_component/sales_order_grid.xml
<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<settings>
<buttons>
<button name="add" class="OrienteedCustomerAgentUiOrderAddButton" />
</buttons>
</settings>
<columns name="sales_order_columns">
<column name="customer_agent" class="OrienteedCustomerAgentUiComponentListingColumnCustomerAgent">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="sortOrder" xsi:type="number">200</item>
<item name="filter" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">Customer Agent</item>
</item>
</argument>
<argument name="customerRepositoryInterface" xsi:type="object">MagentoCustomerApiCustomerRepositoryInterface</argument>
</column>
</columns>
</listing>
and creating app/code/Orienteed/CustomerAgent/Ui/Component/Listing/Column/CustomerAgent.php
<?php
namespace OrienteedCustomerAgentUiComponentListingColumn;
use MagentoFrameworkViewElementUiComponentContextInterface;
use MagentoFrameworkViewElementUiComponentFactory;
use MagentoSalesApiOrderRepositoryInterface;
use MagentoUiComponentListingColumnsColumn;
use MagentoCustomerApiCustomerRepositoryInterface;
class CustomerAgent extends Column
{
protected $orderRepository;
/**
* @var CustomerRepositoryInterface
*/
private $customerRepositoryInterface;
public function __construct(
ContextInterface $context,
UiComponentFactory $uiComponentFactory,
OrderRepositoryInterface $orderRepository,
CustomerRepositoryInterface $customerRepositoryInterface,
array $components = [],
array $data = []
) {
parent::__construct($context, $uiComponentFactory, $components, $data);
$this->orderRepository = $orderRepository;
$this->customerRepositoryInterface = $customerRepositoryInterface;
}
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as &$item) {
$orderId = $item['entity_id'];
$order = $this->orderRepository->get($orderId);
$customerId = $order->getCustomerId();
$customer = $this->customerRepositoryInterface->getById($customerId);
var_dump('getCustomerIdgetCustomerId',$customer,'getCustomerId') ;
if ($customer) {
$customerAgent = $customer->getData('customer_agent')->getRoleName();
$item[$this->getData('name')] = $customerAgent;
}
}
}
return $dataSource;
}
}
but I qot this error
Type Error occurred when creating object: OrienteedCustomerAgentUiComponentListingColumnCustomerAgent, OrienteedCustomerAgentUiComponentListingColumnCustomerAgent::__construct(): Argument #4 ($customerRepositoryInterface) must be of type OrienteedCustomerAgentUiComponentListingColumnMagentoCustomerApiCustomerRepositoryInterface, MagentoCustomerModelResourceModelCustomerRepositoryInterceptor given, called in /app/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 121