Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

243
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda