0

I'd like to make the sales order shipment tracking number (which is present in the sales_shipment_grid table) visible in the Shipments grid for an order in the Admin:

enter image description here

I understand I need to create a module and UpgradeSchema.php but I'm not sure on the details. If anyone can give me some steps that would be great :) Thanks

1 Answer 1

0

In Magento 2, the tracking number for a shipment is not visible in the Sales Order Shipment Grid by default. However, you can add the tracking number to the grid by following these steps:

  1. Create a new file called "sales_shipment_grid.xml" in your custom module's "view/adminhtml/ui_component" directory.

  2. Add the following code to the new file, which will add a new column to the grid displaying the tracking number:

     <column name="tracking_number">
     <argument name="data" xsi:type="array">
         <item name="config" xsi:type="array">
             <item name="filter" xsi:type="string">text</item>
             <item name="label" xsi:type="string" translate="true">Tracking Number</item>
         </item>
     </argument>
    
  3. In your custom module's etc/adminhtml directory, create a new file called "di.xml" and add the following code to it

     <virtualType name="Magento\Sales\Model\ResourceModel\Order\Shipment\Grid" type="Magento\Sales\Model\ResourceModel\Grid">
     <arguments>
         <argument name="columns" xsi:type="array">
             <item name="tracking_number" xsi:type="string">sales_shipment.tracking_number</item>
         </argument>
     </arguments>
    
  4. Clear the cache and refresh the Sales Order Shipment Grid page in the Magento 2 admin panel. The tracking number column should now be visible in the grid.

Note: It's worth noting that this process will only add the tracking number to the grid, it will not be able to add tracking number to the shipment if the shipping method doesn't support it. Also, this process only works if you are using the default grid provided by Magento 2. If the grid has been modified by a third-party extension or custom code, this process might not work as expected.

1
  • Hi, many thanks for your reply. I followed the steps to add your code to my custom module but the tracking number column does not show up in the shipment grid. I don't have any third party extension that modifies the grid nor any custom code.
    – eleventy
    Commented Jan 20, 2023 at 11:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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