We have migrated orders data but old orders we have sales_order_grid & sales_order order status is Delivered but in M2 we are considering status as delivered
We would like to adjust the order grid column to use both formats. please advise
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityI got the answer to this question here are the steps which will help for the stack users if require
Create app/code/Magento/Stackexchange/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">
<columns name="sales_order_columns">
<column name="status" class="Magento\Stackexchange\Ui\Component\Listing\Column\Status">
<settings>
<filter>select</filter>
<options class="Magento\Sales\Ui\Component\Listing\Column\Status\Options"/>
<dataType>select</dataType>
<label translate="true">Status</label>
</settings>
</column>
</columns>
Create app/code/Magento/Stackexchange/Ui/Component/Listing/Column/Status.php
<?php
namespace Magento\Stackexchange\Ui\Component\Listing\Column;
use Magento\Ui\Component\Listing\Columns\Column;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Sales\Api\OrderRepositoryInterface;
class Status extends Column
{
/**
* @var OrderRepositoryInterface
*/
private $orderRepository;
/**
* status constructor.
*
* @param ContextInterface $context
* @param UiComponentFactory $uiComponentFactory
* @param OrderRepositoryInterface $orderRepository
* @param array $components
* @param array $data
*/
public function __construct(
ContextInterface $context,
UiComponentFactory $uiComponentFactory,
OrderRepositoryInterface $orderRepository,
array $components = [],
array $data = []
) {
$this->orderRepository = $orderRepository;
parent::__construct($context, $uiComponentFactory, $components, $data);
}
/**
* Prepare Data Source
*
* @param array $dataSource
* @return array
*/
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as & $item) {
$order = $this->orderRepository->get($item["entity_id"]);
$isStatus = $order->getData("status");
if($isStatus == 'Delivered') {
$isStatus='delivered';
}
$item[$this->getData('name')] = $isStatus;
}
}
return $dataSource;
}
}