Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

241
Views
Magento 2: Add Grid Column to Admin Sales Order Without Adding Column to Database?

I want to add a column to sales order grid on magento admin dashboard. But the value of the column is from some process, not from database. Is that possible? And how to do it? Thanks in advance.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can add a column to the admin grid by adding a file called view/adminhtml/ui_component/sales_order_grid.xml to your custom module with the following content:

<?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">
    <listingToolbar name="listing_top"/>
    <columns name="sales_order_columns">
        <column name="order_reference" class="Vendor\Example\Ui\Component\Listing\Column\Example">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="dataType" xsi:type="string">text</item>
                    <item name="visible" xsi:type="boolean">true</item>
                    <item name="label" xsi:type="string" translate="true">Example Column</item>
                </item>
            </argument>
        </column>
    </columns>
</listing>

Your Example.php-file should extend Magento\Ui\Component\Listing\Columns\Column and have a prepareDataSource()-method to populate the data:

/**
 * @param array $dataSource
 * @return array
 */
public function prepareDataSource(array $dataSource)
{
    if (isset($dataSource['data']['items'])) {
        foreach ($dataSource['data']['items'] as & $item) {
            $item[$this->getData('name')] = 'Something'
        }
    }

    return $dataSource;
}

Note that if you want to add sort- and filter-options you need to add some other adjustments, but that depends on what kind of data you want to show in the column.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!