Hello guys I need your help to know how to add new column "tracking/mobile number" to sales grid.
1 Answer
if this mobile column is already available in sales_order_grid table then just copy this file into you custom module Magento\Sales\view\adminhtml\ui_component\sales_order_grid.xml
to Vendor\Module\view\adminhtml\ui_component\sales_order_grid.xml
Now inside Vendor\Module\view\adminhtml\ui_component\sales_order_grid.xml
file add the below line.
<column name="mobile" >
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="visible" xsi:type="boolean">false</item>
<item name="filter" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">Mobile</item>
</item>
</argument>
</column>
the above code will come under-
<columns name="sales_order_columns">
....
.....
</columns>
mobile is column name in you database
-
Hi Mohammad, i tried this its show mobile field but empty. Do you have any idea how to call it? Thank you– MagEGYMay 9, 2017 at 13:43
-
did you check if mobile field is available in sales_order_grid table. May 9, 2017 at 15:15
-
No its not available in sales_order_grid table i found it inside sales_order_address table under telephone name So the question now how to tell xml file call data from sales_order_address– MagEGYMay 9, 2017 at 21:07
-
Joining two tables just for one field is not good idea instead add new column in sales_order_grid and insert the data in that column after order is placed. still if you want to join you can refer this question. magento.stackexchange.com/questions/123198/… May 10, 2017 at 4:42
-
I dont prefers this way also but i cant do it without joining. do you have any idea how to insert column from sales_order_address and sales_shipment_track to sales_order_grid to be able to call it inside order grid ?– MagEGYMay 10, 2017 at 21:39