1

I want to add one column in order page which is show in admin panle i update my database in sales_order and sales_order_grid by using upgrade scheme but i does not show in order in admin panel please help me thank you xml file here text true newcoll

0

If you've already added the column(s) in the sales_order_grid the next step is to define the column in an ui_component extension in your module. To do this for the order grid create a file app/code/YourVendor/YourModule/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="your_column_field">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="filter" xsi:type="string">text</item>
                    <item name="visible" xsi:type="boolean">true</item>
                    <item name="label" xsi:type="string" translate="true">Your Label Here</item>
                </item>
            </argument>
        </column>
    </columns>
</listing>
  • when i write above code and go to admin panel there is no change but warning message "One or more integrations have been reset because of a change to their xml configs. " what is it ? – Wahaj Moin Jul 11 '18 at 15:42
  • Did you change "you_column_field" to the right column name? Not sure about the message though. – sduif Jul 12 '18 at 6:59
0

I created a UI component sales_order_grid.xml under

[Vendor]/[Module]/view/adminhtml/ui_component/sales_order_grid.xml

and add the following code to your 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="export_status" class="[Vendor]\[Module]\Ui\Component\Listing\Column\Giftstatus">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="visible" xsi:type="boolean">true</item>
                    <item name="label" xsi:type="string" translate="true">Gift Option</item>
                </item>
            </argument>
        </column>
    </columns>
</listing>

Then created the UI class under

[Vendor]/[Module]/Ui/Component/Listing/Column/Giftstatus.php

add the following code to your Giftstatus.php:

<?php
namespace Vendor\Module\Ui\Component\Listing\Column;

use \Magento\Sales\Api\OrderRepositoryInterface;
use \Magento\Framework\View\Element\UiComponent\ContextInterface;
use \Magento\Framework\View\Element\UiComponentFactory;
use \Magento\Ui\Component\Listing\Columns\Column;
use \Magento\Framework\Api\SearchCriteriaBuilder;

class Giftstatus extends Column
{
    protected $_orderRepository;
    protected $_searchCriteria;

    public function __construct(ContextInterface $context, UiComponentFactory $uiComponentFactory, OrderRepositoryInterface $orderRepository, SearchCriteriaBuilder $criteria, array $components = [], array $data = [])
    {
        $this->_orderRepository = $orderRepository;
        $this->_searchCriteria  = $criteria;
        parent::__construct($context, $uiComponentFactory, $components, $data);
    }

    public function prepareDataSource(array $dataSource)
    {
        if (isset($dataSource['data']['items'])) {
            foreach ($dataSource['data']['items'] as & $item) {

                $order  = $this->_orderRepository->get($item["entity_id"]);
                $status = $order->getData("gift_message_id");

                if($status){
                    $message = 'Yes';
                }
                else{
                    $message = 'No';
                }

                $item[$this->getData('name')] = $message;
            }
        }

        return $dataSource;
    }
}

This is working for Gift Option is there or not. You can modify it according to your requirement.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.