Magento add a column in sales shipment grid in Backend

Magento add a column in sales shipment grid in Backend

October 1, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento add a column in sales shipment grid in Backend

Adding a Company Name Column to the Magento Shipment Grid

In Magento, the sales shipment grid in the backend does not display the company name of each order by default. To add this column, you need to modify the Grid.php file located at /app/code/core/Mage/Adminhtml/Block/Sales/Shipment/Grid.php. Here’s a step-by-step guide on how to achieve this:

Understanding the Current Grid Configuration

The current grid configuration is defined in the _prepareColumns() function. It includes columns for shipment ID, creation date, order ID, order creation date, shipping name, total quantity shipped, and an action column.

protected function _prepareColumns()
{
    // ... existing code ...

    $this->addColumn('company_name', array(
        'header' => Mage::helper('sales')->__('Company Name'),
        'index' => 'company_name',
        'type' => 'text',
    ));

    // ... remaining columns ...
}

The Missing Company Name

The issue lies in the fact that the order entity does not have a direct attribute for company name. However, we can retrieve this information using the customer ID associated with each order.

Joining the Customer Table

To display the company name, we need to join the sales_flat_order and customer_entity tables using the customer_id field in the sales_flat_order table. We can do this in the _prepareCollection() function:

protected function _prepareCollection()
{
    $collection = Mage::getResourceModel($this->_getCollectionClass());
    $collection->getSelect()->join(
        array('customer' => 'customer_entity'),
        'main_table.customer_id = customer.entity_id',
        array('company_name' => 'company_name')
    );

    $this->setCollection($collection);
    return parent::_prepareCollection();
}

In this code snippet, we are joining the main table (sales_flat_order) with the customer_entity table on the customer_id field. We then select the company_name column from the joined customer_entity table.

Updating the Column Configuration

After the join, you need to update the index of the company name column in the _prepareColumns() function:

protected function _prepareColumns()
{
    // ... existing code ...

    $this->addColumn('company_name', array(
        'header' => Mage::helper('sales')->__('Company Name'),
        'index' => 'customer.company_name',
        'type' => 'text',
    ));

    // ... remaining columns ...
}

In the updated column configuration, we change the index to customer.company_name to match the joined table.

Conclusion

To add a company name column to the Magento shipment grid:

  1. Create a local copy of the core Grid.php file at /app/code/local/Mage/Adminhtml/Block/Sales/Shipment/Grid.php.
  2. Modify the _prepareCollection() function to join the customer_entity table with the sales_flat_order table.
  3. Update the index of the company name column in the _prepareColumns() function.

After making these changes, clear your Magento cache and refresh the shipment grid page. You should now see a new column for “Company Name” displaying the company names associated with each order.

For more advanced customizations and optimizations to your Magento backend grids, I recommend checking out our comprehensive guides at Laravel Company.

Database Admin Configuration Orders

Our network